Skip to content
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

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

Closed
Tracked by #212 ...
nickelc opened this issue Jul 13, 2020 · 6 comments · Fixed by #4805
Closed
Tracked by #212 ...

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

nickelc opened this issue Jul 13, 2020 · 6 comments · Fixed by #4805
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing

Comments

@nickelc
Copy link
Contributor

nickelc commented Jul 13, 2020

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

@nickelc nickelc added the C-bug Category: Updating dependencies label Jul 13, 2020
@pksunkara pksunkara modified the milestone: 3.0 Jul 19, 2020
@pksunkara
Copy link
Member

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

@pksunkara pksunkara added this to the 3.0 milestone Jul 19, 2020
@pksunkara
Copy link
Member

@CreepySkeleton Need your opinion on this.

@CreepySkeleton
Copy link
Contributor

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).

@pksunkara pksunkara modified the milestones: 3.0, 4.0 Oct 9, 2021
@epage epage modified the milestones: 4.0, 3.0 Oct 9, 2021
@epage
Copy link
Member

epage commented Oct 9, 2021

In case people want history, replace was added in #1697 to resolve #1603

@epage epage removed this from the 3.0 milestone Oct 9, 2021
@epage
Copy link
Member

epage commented Oct 9, 2021

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

@epage epage added A-help Area: documentation, including docs.rs, readme, examples, etc... S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing and removed C: alias labels Dec 8, 2021
@epage
Copy link
Member

epage commented Mar 23, 2023

Cross posting from #2836 for greater visibility

Due to the lack of interest on this tracking issue, I'm considering removing this unstable feature.

Any concerns people want to raise?

epage added a commit to epage/clap that referenced this issue Mar 28, 2023
This has been implemented for 3 years without much traction for
finishing it up.

The subcommand use case can be worked around by creating `Command`s that
just include the relevant logic, very similar to the default subcommand
examples in `git` / `git-derive`.

Using this for flags is covered by clap-rs#4793.

Without `unstable-replace` being enabled, this still cut 5 KiB from
`cargo bloat --release --example git`.

Closes clap-rs#2011
epage added a commit to epage/clap that referenced this issue Mar 28, 2023
This has been implemented for 3 years without much traction for
finishing it up.

The subcommand use case can be worked around by creating `Command`s that
just include the relevant logic, very similar to the default subcommand
examples in `git` / `git-derive`.

Using this for flags is covered by clap-rs#4793.

Without `unstable-replace` being enabled, this still cut 5 KiB from
`cargo bloat --release --example git`.

Closes clap-rs#2836
Closes clap-rs#2011
@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-help Area: documentation, including docs.rs, readme, examples, etc... C-bug Category: Updating dependencies S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants