From 58f545f240068d46105478e104a27eb87af768d8 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 18 Aug 2017 14:21:18 -0700 Subject: [PATCH] :fire: Stop parsing flags after positional args (#219) This allows things like the following to work as, I hope, one would expect: commit +flags: git commit {{flags}} $ just commit -a It is however a breaking change, so also bump version number to 0.3.0. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/app.rs | 1 + src/integration.rs | 18 +++++++++++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f3c0ee..0035f47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "just" -version = "0.2.33" +version = "0.3.0" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 995d965..fc3c110 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "just" -version = "0.2.33" +version = "0.3.0" description = "🤖 Just a command runner" authors = ["Casey Rodarmor "] license = "WTFPL OR MIT OR Apache-2.0" diff --git a/src/app.rs b/src/app.rs index eaab3be..4d3a89c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -36,6 +36,7 @@ pub fn app() { .author(env!("CARGO_PKG_AUTHORS")) .about(concat!(env!("CARGO_PKG_DESCRIPTION"), " - ", env!("CARGO_PKG_HOMEPAGE"))) .setting(AppSettings::ColoredHelp) + .setting(AppSettings::TrailingVarArg) .arg(Arg::with_name("ARGUMENTS") .multiple(true) .help("The recipe(s) to run, defaults to the first recipe in the justfile")) diff --git a/src/integration.rs b/src/integration.rs index b2f0e7b..c97c00c 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -52,8 +52,8 @@ fn integration_test( let output = process::Command::new(&super::test_utils::just_binary_path()) .current_dir(tmp.path()) - .args(args) .args(&["--shell", shell]) + .args(args) .output() .expect("just invocation failed"); @@ -409,7 +409,7 @@ integration_test! { echo hello echo {{`exit 111`}} a = `exit 222`", - args: ("--set", "foo", "bar", "a", "b", "--set", "baz", "bob", "--set", "a", "b"), + args: ("--set", "foo", "bar", "--set", "baz", "bob", "--set", "a", "b", "a", "b"), stdout: "", stderr: "error: Variables `baz` and `foo` overridden on the command line but not present \ in justfile\n", @@ -551,7 +551,7 @@ export ABC = FOO + "-" + BAR + "-" + baz wut: echo $FOO $BAR $ABC "#, - args: ("FOO=hello", "--set", "BAR", "bye"), + args: ("--set", "BAR", "bye", "FOO=hello"), stdout: "hello bye hello-bye-c\n", stderr: "echo $FOO $BAR $ABC\n", status: EXIT_SUCCESS, @@ -1584,3 +1584,15 @@ a: stderr: "\u{1b}[1;36m===> Running recipe `a`...\u{1b}[0m\n\u{1b}[1mecho hi\u{1b}[0m\n", status: EXIT_SUCCESS, } + +integration_test! { + name: trailing_flags, + justfile: " +echo A B C: + echo {{A}} {{B}} {{C}} +", + args: ("echo", "--some", "--awesome", "--flags"), + stdout: "--some --awesome --flags\n", + stderr: "echo --some --awesome --flags\n", + status: EXIT_SUCCESS, +}