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

feat(complete): generate completions for visible aliases #5476

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on May 17, 2024

  1. fix(complete): Fix zsh.rs subcommand deduplication

    Fixing the iteration over all_subcommands in zsh.rs. We deduplicate
    values on (sc_name, bin_name) keys, but then only iterate on bin_name.
    This doesn't cause problems now, since all bin names seem to be unique.
    However, without fixing this, the next commit would have started
    generating duplicated functions with same names.
    
    For example, with an #[long = "foo", visible_alias = "bar"] subcommand,
    we'll end up with 2 pairs: [("foo", "foo"), ("bar", "foo")]. Before this
    commit, we would have ended up generating _my-app__foo_commands()
    functions. These functions should have identical content, so it is not
    an error, just an inefficiency that we can fix.
    pzmarzly committed May 17, 2024
    Configuration menu
    Copy the full SHA
    be15bd5 View commit details
    Browse the repository at this point in the history
  2. feat(complete): Add autocomplete for visible_alias

    Let's generate autocompletions for aliased subcommands.
    
        $ source before.zsh
        $ clap-test [TAB] <- gives me "foo bar --"
        $ clap-test foo [TAB] <- gives me "--my-flag"
        $ clap-test bar [TAB] <- no reaction
    
        $ source after.zsh
        $ clap-test [TAB] <- gives me "foo bar --"
        $ clap-test foo [TAB] <- gives me "--my-flag"
        $ clap-test bar [TAB] <- gives me "--my-flag"
    pzmarzly committed May 17, 2024
    Configuration menu
    Copy the full SHA
    5000d58 View commit details
    Browse the repository at this point in the history