1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
# This file defines completions for an `example` program with subcommands.
#
# The `example start` subcommand works like sudo, it takes a command with
# arguments.
#
# Options:
#
# -h|--help:
# If this option is specified, no more options will be suggested.
#
# -v|--verbose:
# This option may be specified multiple times.
#
# --deprecated-option:
# This option will not be shown in the option suggestions.
#
# --preserve-env:
# This option takes a comma-separated list of environment variables.
#
# --foreground | --background:
# These options are mutually exclusive.
#
# --pid-file:
# This option will only be suggested if --background is given.
#
# -o|--options:
# This option takes a comma-separated list of key=value pairs.
#
# --pager:
# This option takes an *optional* argument.
#
# Examples:
#
# $ example start -vvv firefox http://example.com
# $ example start --background --pid-file foo.pid firefox
# $ example launch -o user=benny,group=benny firefox
# $ example view-log --pager
# $ example view-log --pager=less
#
# Note: For reasons of clarity, `help` parameter has been omitted.
# Defines can be handy if completers are reused or to keep the definition clean
prog: '%defines%'
complete_priority: ['choices', {
'low': 'Run with lowest priority, background tasks only',
'normal': 'Standard scheduling priority for regular tasks',
'high': 'Higher priority for time-sensitive operations',
'realtime': 'Real-time scheduling, may affect system responsiveness'
}]
complete_options: ['key_value_list', ',', '=', [
['lang', 'set language', ['locale']],
['user', 'set user', ['user']],
['group', 'set group', ['group']],
]]
---
prog: 'example'
options:
- option_strings: ['-h', '--help']
final: true # don't allow further options after this option
---
prog: 'example start'
aliases: ['launch'] # Also allow 'example launch'
options:
- option_strings: ['-v', '--verbose']
repeatable: true # This option can appear more than once
- option_strings: ['--deprecated-option']
hidden: true # Since deprecated, make this option hidden
- option_strings: ['--preserve-env']
complete: ['list', ['environment']] # Comma-separated list of env vars
- option_strings: ['--priority']
complete: 'complete_priority' # see %defines%
nosort: true # Do not sort choices alphabetically; keep order
# --foreground and --background are mutually exclusive
- option_strings: ['--foreground']
groups: ['start_mode']
- option_strings: ['--background']
groups: ['start_mode']
- option_strings: ['--pid-file']
complete: ['file']
when: 'has_option --background' # Only show this option if --background
# Comma-separated list of key=value Options, like `mount -o`
- option_strings: ['-o', '--options']
complete: 'complete_options' # see %defines%
positionals:
- number: 1
metavar: 'command'
complete: ['command']
- number: 2
metavar: 'argument'
repeatable: true
complete: ['command_arg']
---
prog: 'example view-log'
options:
- option_strings: ['--pager']
metavar: 'command'
complete: ['command']
optional_arg: true # Allow --pager without argument
|