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