-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Labels
area/v3relates to / is being considered for v3relates to / is being considered for v3kind/bugdescribes or fixes a bugdescribes or fixes a bug
Description
This issue proposes improvements to the behavior of the completion command.
Current Issues
- The
completioncommand does not parse flags, so it does not support the--helpflag and returns an error.
completion --help
unknown shell --help, available shells are [bash fish pwsh zsh]
- Since the
completioncommand 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 --fooare 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
bashandzshare not treated as subcommands,completion help bashandcompletion bash --helpdo 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
completioncommand.- Add support for
--help. - Provide more appropriate error messages for unknown flags.
- Add support for
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
bashandzshas subcommands.completion help bashandcompletion bash --helpshould 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
completioncommand, 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
- Required flag breaks completion generation #2238
- Fix:(issue_2238) Dont process flags for completion command #2239
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/v3relates to / is being considered for v3relates to / is being considered for v3kind/bugdescribes or fixes a bugdescribes or fixes a bug