Skip to content

Commit 495e13c

Browse files
authored
Merge pull request #233 from BurntSushi/clap
Switch from Docopt to Clap.
2 parents a3f5e0c + 92dc402 commit 495e13c

14 files changed

+1173
-656
lines changed

.travis.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,10 @@ matrix:
3030
env: TARGET=x86_64-apple-darwin
3131
# Minimum Rust supported channel.
3232
- os: linux
33-
rust: 1.9.0
34-
env: TARGET=x86_64-unknown-linux-musl
35-
- os: linux
36-
rust: 1.9.0
33+
rust: 1.11.0
3734
env: TARGET=x86_64-unknown-linux-gnu
3835
- os: osx
39-
rust: 1.9.0
36+
rust: 1.11.0
4037
env: TARGET=x86_64-apple-darwin
4138

4239
before_install:

Cargo.lock

+58-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ readme = "README.md"
1313
keywords = ["regex", "grep", "egrep", "search", "pattern"]
1414
license = "Unlicense/MIT"
1515
exclude = ["HomebrewFormula"]
16+
build = "build.rs"
1617

1718
[[bin]]
1819
bench = false
@@ -25,8 +26,8 @@ path = "tests/tests.rs"
2526

2627
[dependencies]
2728
bytecount = "0.1.4"
29+
clap = "2.18"
2830
ctrlc = "2.0"
29-
docopt = "0.6"
3031
env_logger = "0.3"
3132
grep = { version = "0.1.4", path = "grep" }
3233
ignore = { version = "0.1.5", path = "ignore" }
@@ -37,13 +38,16 @@ memchr = "0.1"
3738
memmap = "0.5"
3839
num_cpus = "1"
3940
regex = "0.1.77"
40-
rustc-serialize = "=0.3.19"
4141
term = "0.4"
4242

4343
[target.'cfg(windows)'.dependencies]
4444
kernel32-sys = "0.2"
4545
winapi = "0.2"
4646

47+
[build-dependencies]
48+
clap = "2.18"
49+
lazy_static = "0.2"
50+
4751
[features]
4852
avx-accel = ["bytecount/avx-accel"]
4953
simd-accel = ["bytecount/simd-accel", "regex/simd-accel"]

build.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#[macro_use]
2+
extern crate clap;
3+
#[macro_use]
4+
extern crate lazy_static;
5+
6+
use std::fs;
7+
8+
use clap::Shell;
9+
10+
#[allow(dead_code)]
11+
#[path = "src/app.rs"]
12+
mod app;
13+
14+
fn main() {
15+
fs::create_dir_all(env!("OUT_DIR")).unwrap();
16+
17+
let mut app = app::app_short();
18+
app.gen_completions("rg", Shell::Bash, env!("OUT_DIR"));
19+
app.gen_completions("rg", Shell::Fish, env!("OUT_DIR"));
20+
// Zsh seems to fail with a panic.
21+
// app.gen_completions("rg", Shell::Zsh, env!("OUT_DIR"));
22+
app.gen_completions("rg", Shell::PowerShell, env!("OUT_DIR"));
23+
}

ci/before_deploy.sh

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mk_tarball() {
1919

2020
cp target/$TARGET/release/rg "$td/$name/"
2121
cp {doc/rg.1,README.md,UNLICENSE,COPYING,LICENSE-MIT} "$td/$name/"
22+
cp target/$TARGET/release/build/ripgrep-*/out/{_rg.,rg.}* "$td/$name/"
2223

2324
pushd $td
2425
tar czf "$out_dir/$name.tar.gz" *

doc/rg.1

+22-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
rg \- recursively search current directory for lines matching a pattern
88
.SH SYNOPSIS
99
.PP
10-
rg [\f[I]options\f[]] \-e PATTERN ...
11-
[\f[I]<\f[]path\f[I]> ...\f[]]
12-
.PP
1310
rg [\f[I]options\f[]] <\f[I]pattern\f[]> [\f[I]<\f[]path\f[I]> ...\f[]]
1411
.PP
12+
rg [\f[I]options\f[]] (\-e PATTERN | \-f FILE) ...
13+
[\f[I]<\f[]path\f[I]> ...\f[]]
14+
.PP
1515
rg [\f[I]options\f[]] \-\-files [\f[I]<\f[]path\f[I]> ...\f[]]
1616
.PP
1717
rg [\f[I]options\f[]] \-\-type\-list
@@ -163,6 +163,15 @@ Show debug messages.
163163
.RS
164164
.RE
165165
.TP
166+
.B \-f, \-\-file FILE ...
167+
Search for patterns from the given file, with one pattern per line.
168+
When this flag is used or multiple times or in combination with the
169+
\-e/\-\-regexp flag, then all patterns provided are searched.
170+
Empty pattern lines will match all input lines, and the newline is not
171+
counted as part of the pattern.
172+
.RS
173+
.RE
174+
.TP
166175
.B \-\-files
167176
Print each file that would be searched (but don\[aq]t search).
168177
.RS
@@ -202,6 +211,16 @@ Search hidden directories and files.
202211
.RS
203212
.RE
204213
.TP
214+
.B \-\-ignore\-file FILE ...
215+
Specify additional ignore files for filtering file paths.
216+
Ignore files should be in the gitignore format and are matched relative
217+
to the current working directory.
218+
These ignore files have lower precedence than all other ignore files.
219+
When specifying multiple ignore files, earlier files have lower
220+
precedence than later files.
221+
.RS
222+
.RE
223+
.TP
205224
.B \-L, \-\-follow
206225
Follow symlinks.
207226
.RS

doc/rg.1.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ rg - recursively search current directory for lines matching a pattern
44

55
# SYNOPSIS
66

7-
rg [*options*] -e PATTERN ... [*<*path*> ...*]
8-
97
rg [*options*] <*pattern*> [*<*path*> ...*]
108

9+
rg [*options*] (-e PATTERN | -f FILE) ... [*<*path*> ...*]
10+
1111
rg [*options*] --files [*<*path*> ...*]
1212

1313
rg [*options*] --type-list
@@ -107,6 +107,12 @@ Project home page: https://github.com/BurntSushi/ripgrep
107107
--debug
108108
: Show debug messages.
109109

110+
-f, --file FILE ...
111+
: Search for patterns from the given file, with one pattern per line. When this
112+
flag is used or multiple times or in combination with the -e/--regexp flag,
113+
then all patterns provided are searched. Empty pattern lines will match all
114+
input lines, and the newline is not counted as part of the pattern.
115+
110116
--files
111117
: Print each file that would be searched (but don't search).
112118

@@ -132,6 +138,14 @@ Project home page: https://github.com/BurntSushi/ripgrep
132138
: Search hidden directories and files. (Hidden directories and files are
133139
skipped by default.)
134140

141+
--ignore-file FILE ...
142+
: Specify additional ignore files for filtering file paths.
143+
Ignore files should be in the gitignore format and are matched
144+
relative to the current working directory. These ignore files
145+
have lower precedence than all other ignore files. When
146+
specifying multiple ignore files, earlier files have lower
147+
precedence than later files.
148+
135149
-L, --follow
136150
: Follow symlinks.
137151

0 commit comments

Comments
 (0)