Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

Help subcommand behaves different than help flags when App::replace is used #158

Open
epage opened this issue Dec 6, 2021 · 5 comments
Open

Comments

@epage
Copy link
Owner

epage commented Dec 6, 2021

Issue by nickelc
Monday Jul 13, 2020 at 17:33 GMT
Originally opened as clap-rs/clap#2011


Using clap master

Code

use clap::clap_app;

fn main() {
    let app = clap_app!(prog =>
        (replace: "install", &["module", "install"])
        (@subcommand module =>
            (@subcommand "install" =>
                (about: "Install module")
            )
        )
    );
    app.get_matches();
}

Steps to reproduce the issue

  1. Run cargo r -- install --help
  2. Run cargo r -- help install

cargo r -- install --help Output

prog-module-install 
Install module

USAGE:
    prog module install

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

cargo r -- help install Output

error:  The subcommand 'install' wasn't recognized

USAGE:
	prog help <subcommands>...

For more information try --help

I expected the replacement of help install with help module install

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by pksunkara
Sunday Jul 19, 2020 at 12:50 GMT


I am still deciding whether this is intended or not. replace is similar to aliases but for more args than just one.

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by pksunkara
Sunday Aug 23, 2020 at 05:05 GMT


@CreepySkeleton Need your opinion on this.

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by CreepySkeleton
Sunday Aug 23, 2020 at 09:27 GMT


My opinion is that replace was a badly designed feature. Something that OP described (cross-level subcommand aliases) was the reason replace was added in the first place, and while it does kinda solve the problem, it adds more problems (help messages don't mention it at all and there's no way for them to do so, malfunctioning help subcommand) and it doesn't quite blend with the rest of the machinery (essentially being a C-like dumb preprocessor the rest of clap isn't even aware of).

I think the solution here is to develop a working cross-level aliasing mechanism (and possibly ditch replace but that questionable).

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by epage
Saturday Oct 09, 2021 at 10:45 GMT


In case people want history, replace was added in clap-rs/clap#1697 to resolve clap-rs/clap#1603

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by epage
Saturday Oct 09, 2021 at 15:50 GMT


Cleared the milestone since it looks like we are punting on this by putting App::replace behind a feature flag. See clap-rs/clap#2836

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant