mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 03:11:13 -03:00
Added way to tell argparse to delete an option from $argv_opts.
The intention is that if you want to parse some of your options verbatim to another command, but you want to modfy other options (e.g. change their value, convert them to other options, or delete them entirely), you mark the options you want to modify with an &, and argparse will not add them to argv_opts. You can then call the other command with argv_opts together with any new/modified options, ensuring that the other command doesn't set the pre-modified options. As with other known options, & options will be removed from $argv, and have their $_flag_ variables set. The `&` goes at the end of the option spec, or if the option spec contains a validation script, immediately before the `!`. There is also now a -d/--delete flag to fish_opt that will generate such an option spec. See the changes in doc_src/cmds/argparse.rst for more details and an example use case.
This commit is contained in:
@@ -8,7 +8,7 @@ Synopsis
|
||||
|
||||
.. synopsis::
|
||||
|
||||
fish_opt -s ALPHANUM [-l LONG-NAME] [-or] [--multiple-vals] [--long-only]
|
||||
fish_opt -s ALPHANUM [-l LONG-NAME] [-ord] [--multiple-vals] [--long-only]
|
||||
fish_opt --help
|
||||
|
||||
Description
|
||||
@@ -36,6 +36,10 @@ The following ``argparse`` options are available:
|
||||
**--multiple-vals**
|
||||
The option being defined requires a value each time it is seen. Each instance is stored. This means the resulting flag variable created by ``argparse`` will have one element for each instance of this option in the arguments.
|
||||
|
||||
**-d** or **--delete**
|
||||
The option and any values will be deleted from the ``$argv_opts`` variables set by ``argparse``
|
||||
(as with other options, it will also be deleted from ``$argv``).
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user