Skip to content

Commit

Permalink
Fix leading hypen bug by updating clap.
Browse files Browse the repository at this point in the history
Fixes #270
  • Loading branch information
BurntSushi committed Dec 6, 2016
1 parent 86f8c3c commit d668121
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ path = "tests/tests.rs"

[dependencies]
bytecount = "0.1.4"
clap = "~2.18.0"
clap = "~2.19.0"
ctrlc = "2.0"
env_logger = "0.3"
grep = { version = "0.1.4", path = "grep" }
Expand Down
3 changes: 2 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use clap::{App, AppSettings, Arg};
use clap::{App, AppSettings, Arg, ArgSettings};

const ABOUT: &'static str = "
ripgrep (rg) recursively searches your current directory for a regex pattern.
Expand Down Expand Up @@ -74,6 +74,7 @@ fn app<F>(next_line_help: bool, doc: F) -> App<'static, 'static>
.arg(arg("path").multiple(true))
.arg(flag("regexp").short("e")
.takes_value(true).multiple(true).number_of_values(1)
.set(ArgSettings::AllowLeadingHyphen)
.value_name("pattern"))
.arg(flag("files")
// This should also conflict with `pattern`, but the first file
Expand Down
12 changes: 12 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,18 @@ fn regression_64() {
assert_eq!(lines, path("foo/abc\n"));
}

// See: https://github.com/BurntSushi/ripgrep/issues/270
#[test]
fn regression_270() {
let wd = WorkDir::new("regression_270");
wd.create("foo", "-test");

let mut cmd = wd.command();
cmd.arg("-e").arg("-test");
let lines: String = wd.stdout(&mut cmd);
assert_eq!(lines, path("foo:-test\n"));
}

#[test]
fn type_list() {
let wd = WorkDir::new("type_list");
Expand Down

0 comments on commit d668121

Please sign in to comment.