This issue proposes improvements to the behavior of the completion command.
Current Issues
- The
completion command does not parse flags, so it does not support the --help flag and returns an error.
completion --help
unknown shell --help, available shells are [bash fish pwsh zsh]
- Since the
completion command does not parse flags, specifying an unknown flag results in an unknown shell error.
completion --foo
unknown shell --foo, available shells are [bash fish pwsh zsh]
- Because flags are not parsed, unknown flags such as
completion bash --foo are silently ignored.
completion bash --foo
#!/bin/bash
# This is a shell completion script auto-generated by https://github.com/urfave/cli for bash.
...
- Since shells such as
bash and zsh are not treated as subcommands, completion help bash and completion bash --help do not display help messages.
completion help bash
unknown shell help, available shells are [bash fish pwsh zsh]
completion bash --help
#!/bin/bash
# This is a shell completion script auto-generated by https://github.com/urfave/cli for bash.
...
Proposed Improvements
- Enable flag parsing for the
completion command.
- Add support for
--help.
- Provide more appropriate error messages for unknown flags.
completion --help
NAME:
xxx completion - Output shell completion script for bash, zsh, fish, or Powershell
...
completion --foo
Incorrect Usage: flag provided but not defined: -foo
- Treat shells such as
bash and zsh as subcommands.
completion help bash and completion bash --help should display help messages.
completion help bash
NAME:
xxx completion bash - Output bash completion script
completion bash --help
NAME:
xxx completion bash - Output bash completion script
- Since global options are ignored for the
completion command, remove them from the help message as well.
completion bash --help
NAME:
xxx completion bash - Output bash completion script
USAGE:
xxx completion bash [options]
OPTIONS:
--help, -h show help
Background: Why the completion Command Does Not Parse Flags
Flag parsing was originally disabled for the completion command to avoid errors when global required options were not provided.
In this proposal, flag parsing will be enabled while skipping the validation of required options for the completion command, thereby avoiding the original issue.
This issue proposes improvements to the behavior of the
completioncommand.Current Issues
completioncommand does not parse flags, so it does not support the--helpflag and returns an error.completioncommand does not parse flags, specifying an unknown flag results in an unknown shell error.completion bash --fooare silently ignored.bashandzshare not treated as subcommands,completion help bashandcompletion bash --helpdo not display help messages.Proposed Improvements
completioncommand.--help.bashandzshas subcommands.completion help bashandcompletion bash --helpshould display help messages.completioncommand, remove them from the help message as well.Background: Why the
completionCommand Does Not Parse FlagsFlag parsing was originally disabled for the
completioncommand to avoid errors when global required options were not provided.In this proposal, flag parsing will be enabled while skipping the validation of required options for the
completioncommand, thereby avoiding the original issue.