Skip to content

Support completion for command alias arguments (i.e. flags, options, option values, positional arguments, and/or subcommands) #847

@rgoldberg

Description

@rgoldberg

Support completion for command alias arguments (i.e. flags, options, option values, positional arguments, and/or subcommands).

I think that, at least by default, only the "real" command names (not aliases) should be offered to be completed, but, if an alias is used on the command line, its flags, options, option values, arguments, and subcommands should be offered as completions.

e.g. if you have a command c with a subcommand named real with an alias alias that has flags, options, arguments , and/or subcommands:

# offer real if you tab after r
c r

# do not offer alias if you tab after a
c a

# complete the flags, options, option values, arguments, and/or subcommands for real/alias
c real …

# complete the flags, options, option values, arguments, and/or subcommands for real/alias
c alias

Maybe there could be a setting to also offer aliases when potentially completing to them (e.g., offering alias when tabbing after a), but I don't think that should be the default. The setting could be on a per overall command basis, per subcommands of a specific command, per specific subcommand, or per alias. If I submit a PR for this issue, however, I'd probably leave out any such setting.

ArgumentParser version: main
Swift version: n/a

Checklist

  • If possible, I've reproduced the issue using the main branch of this package
  • I've searched for existing GitHub issues

Steps to Reproduce

  1. Create a command with an alias & some flags
  2. Build
  3. Generate completion scripts
  4. Try to complete one of the flags after the alias
  5. See that no completions offered

Expected behavior

I expect completions for flags, options, option values, arguments, and subcommands to be offered after aliases.

Actual behavior

Completions aren't offered for the alias's args.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions