diff --git a/README.md b/README.md index 66203f3..6e7790c 100644 --- a/README.md +++ b/README.md @@ -25,15 +25,15 @@ The entry point in `bin/awesomecli` can then be: ``` #!/usr/bin/env bash -sub --name awesomecli --bin "${BASH_SOURCE[0]}" --relative ".." -- "$@" +sub --name awesomecli --executable "${BASH_SOURCE[0]}" --relative ".." -- "$@" ``` The `--name` argument tells `sub` the name of the CLI. This is used when printing help information. -The `--bin` argument tells `sub` where the binary entry point is located. +The `--executable` argument tells `sub` where the CLI entry point is located. Usually this will just be `${BASH_SOURCE[0]}`. The `--relative` argument tells -`sub` how to find the root of the CLI starting from the binary entry point. +`sub` how to find the root of the CLI starting from the CLI entry point. These two are separate arguments for cross platform compatibility. `sub` will canonalize the bin path before merging with the relative path and then canonalize again. diff --git a/integration/fixtures/commands/bin/main b/integration/fixtures/commands/bin/main index d3a815f..2791125 100755 --- a/integration/fixtures/commands/bin/main +++ b/integration/fixtures/commands/bin/main @@ -2,4 +2,4 @@ set -e -$SUB_BIN --color never --name main --bin "${BASH_SOURCE[0]}" --relative ".." -- "$@" +$SUB_BIN --color never --name main --executable "${BASH_SOURCE[0]}" --relative ".." -- "$@" diff --git a/integration/fixtures/completions/bin/main b/integration/fixtures/completions/bin/main index d3a815f..2791125 100755 --- a/integration/fixtures/completions/bin/main +++ b/integration/fixtures/completions/bin/main @@ -2,4 +2,4 @@ set -e -$SUB_BIN --color never --name main --bin "${BASH_SOURCE[0]}" --relative ".." -- "$@" +$SUB_BIN --color never --name main --executable "${BASH_SOURCE[0]}" --relative ".." -- "$@" diff --git a/integration/fixtures/project/bin/main b/integration/fixtures/project/bin/main index d3a815f..2791125 100755 --- a/integration/fixtures/project/bin/main +++ b/integration/fixtures/project/bin/main @@ -2,4 +2,4 @@ set -e -$SUB_BIN --color never --name main --bin "${BASH_SOURCE[0]}" --relative ".." -- "$@" +$SUB_BIN --color never --name main --executable "${BASH_SOURCE[0]}" --relative ".." -- "$@" diff --git a/integration/sub.bats b/integration/sub.bats index c64f800..0b7be90 100644 --- a/integration/sub.bats +++ b/integration/sub.bats @@ -10,10 +10,10 @@ PROJECT_DIR="$SUB_TEST_DIR/project" assert_output "main: libexec directory not found in root" } -@test "sub: reject --bin and --absolute given together" { +@test "sub: reject --executable and --absolute given together" { fixture "project" - run $SUB_BIN --name main --bin "$PROJECT_DIR" --absolute "$PROJECT_DIR" + run $SUB_BIN --name main --executable "$PROJECT_DIR" --absolute "$PROJECT_DIR" assert_failure } diff --git a/src/main.rs b/src/main.rs index 2186be5..1af03e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -167,19 +167,19 @@ fn init_sub_cli() -> Command { Arg::new("name") .long("name") .required(true) - .help("Sets the CLI name. Used in help and error messages."), + .help("Sets the CLI name - used in help and error messages"), ) .arg( - Arg::new("bin") - .long("bin") + Arg::new("executable") + .long("executable") .value_parser(value_parser!(PathBuf)) - .help("Sets the path of the CLI binary. Only use in combination with --relative."), + .help("Sets the path of the CLI executable; only use in combination with --relative"), ) .arg( Arg::new("relative") .long("relative") .value_parser(value_parser!(PathBuf)) - .help("Sets how to find the root directory based on the location of the bin. Only use in combination with --bin."), + .help("Sets how to find the root directory based on the location of the executable; Only use in combination with --executable"), ) .arg( Arg::new("absolute") @@ -197,8 +197,8 @@ fn init_sub_cli() -> Command { .help("Validate that the CLI is correctly configured"), ) .group( - ArgGroup::new("bin_and_relative") - .args(["bin", "relative"]) + ArgGroup::new("executable_and_relative") + .args(["executable", "relative"]) .multiple(true) .conflicts_with("absolute"), ) @@ -305,18 +305,18 @@ fn parse_sub_cli_args() -> SubCliArgs { Some(path) => path.clone(), None => { let mut path = args - .get_one::("bin") - .expect("Either `bin` or `absolute` is required") + .get_one::("executable") + .expect("Either `executable` or `absolute` is required") .canonicalize() - .expect("Invalid `bin` path") + .expect("Invalid `executable` path") .clone(); - path.pop(); // remove bin name + path.pop(); // remove executable name let relative = args.get_one::("relative").expect("Missing `relative` argument"); path.push(relative); - path.canonicalize().expect("Invalid `bin` or `relative` arguments") + path.canonicalize().expect("Invalid `executable` or `relative` arguments") } }, }