-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the --version flag concatenates subcommands #1382
Comments
+1 on this. Thought we had a bug in our implementation but it seems to be the way clap handles versions for subcommands. It can be overridden with a |
This seems like a slight variant on #1431. We should probably look at these together. |
One other aspect of this is that we can have per-subcommand versions. In that case, we probably would want to list what the version is relevant for. |
Updated the code for clap3 use clap::{App, AppSettings, Arg};
fn main() {
let matches = App::new("claptest")
.setting(AppSettings::PropagateVersion)
.version("1.0")
.arg(
Arg::new("config")
.short('c')
.long("config")
.value_name("FILE")
.help("Sets a custom config file")
.takes_value(true),
)
.subcommand(
App::new("test")
.about("print debug information verbosely")
.subcommand(App::new("hello").about("hello")),
)
.get_matches();
}
$ ./target/debug/clap-test --version
claptest 1.0
$ ./target/debug/clap-test test --version
claptest-test 1.0
$ ./target/debug/clap-test test hello --version
claptest-test-test 1.0 instead of $ ./target/debug/clap-test --version
claptest 1.0
$ ./target/debug/clap-test test --version
clap-test-test
$ ./target/debug/clap-test test hello --version
clap-test-test-hello |
I feel like what we show could be derived from the work in #1334 |
Maintainer's notes
Rust Version
rustc 1.31.0-nightly (4bd4e4130 2018-10-25)
Affected Version of clap
2.32.0
Bug or Feature Request Summary
Passing the
--version
flag after one or more subcommands should not append the subcommand names to the process nameExpected Behavior Summary
Actual Behavior Summary
Sample Code or Link to Sample Code
Debug output
Compile clap with cargo features
"debug"
such as:Output for:
./target/debug/clap-test test --version
:Debug Output
this does not look like a critical bug, but it still feels weird :)
The text was updated successfully, but these errors were encountered: