|
| 1 | +name: yml_app |
| 2 | +version: 1.0 |
| 3 | +about: an example using a .yml file to build a CLI |
| 4 | +author: Kevin K. <[email protected]> |
| 5 | + |
| 6 | +# AppSettings can be defined as a list and are **not** ascii case sensitive |
| 7 | +settings: |
| 8 | + - ArgRequiredElseHelp |
| 9 | + |
| 10 | +# All Args must be defined in the 'args:' list where the name of the arg, is the |
| 11 | +# key to a Hash object |
| 12 | +args: |
| 13 | + # The name of this argument, is 'opt' which will be used to access the value |
| 14 | + # later in your Rust code |
| 15 | + - opt: |
| 16 | + help: example option argument from yaml |
| 17 | + short: o |
| 18 | + long: option |
| 19 | + multiple: true |
| 20 | + takes_value: true |
| 21 | + - pos: |
| 22 | + help: example positional argument from yaml |
| 23 | + index: 1 |
| 24 | + # A list of possible values can be defined as a list |
| 25 | + possible_values: |
| 26 | + - fast |
| 27 | + - slow |
| 28 | + - flag: |
| 29 | + help: demo flag argument |
| 30 | + short: F |
| 31 | + multiple: true |
| 32 | + global: true |
| 33 | + # Conflicts, mutual overrides, and requirements can all be defined as a |
| 34 | + # list, where the key is the name of the other argument |
| 35 | + conflicts_with: |
| 36 | + - opt |
| 37 | + requires: |
| 38 | + - pos |
| 39 | + - mode: |
| 40 | + long: mode |
| 41 | + help: shows an option with specific values |
| 42 | + # possible_values can also be defined in this list format |
| 43 | + possible_values: [ vi, emacs ] |
| 44 | + - mvals: |
| 45 | + long: mult-vals |
| 46 | + help: demos an option which has two named values |
| 47 | + # value names can be described in a list, where the help will be shown |
| 48 | + # --mult-vals <one> <two> |
| 49 | + value_names: |
| 50 | + - one |
| 51 | + - two |
| 52 | + - minvals: |
| 53 | + long: min-vals |
| 54 | + multiple: true |
| 55 | + help: you must supply at least two values to satisfy me |
| 56 | + min_values: 2 |
| 57 | + - maxvals: |
| 58 | + long: max-vals |
| 59 | + multiple: true |
| 60 | + help: you can only supply a max of 3 values for me! |
| 61 | + max_values: 3 |
| 62 | + |
| 63 | +# All subcommands must be listed in the 'subcommand:' object, where the key to |
| 64 | +# the list is the name of the subcommand, and all settings for that command are |
| 65 | +# are part of a Hash object |
| 66 | +subcommands: |
| 67 | + # The nae of this subcommand will be 'subcmd' which can be accessed in your |
| 68 | + # Rust code later |
| 69 | + - subcmd: |
| 70 | + about: demos subcommands from yaml |
| 71 | + version: 0.1 |
| 72 | + author: Kevin K. <[email protected]> |
| 73 | + # Subcommand args are exactly like App args |
| 74 | + args: |
| 75 | + - scopt: |
| 76 | + short: B |
| 77 | + multiple: true |
| 78 | + help: example subcommand option |
| 79 | + takes_value: true |
| 80 | + - scpos1: |
| 81 | + help: example subcommand positional |
| 82 | + index: 1 |
| 83 | + |
| 84 | +# ArgGroups are supported as well, and must be sepcified in the 'arg_groups:' |
| 85 | +# object of this file |
| 86 | +arg_groups: |
| 87 | + # the name of the ArgGoup is specified here |
| 88 | + - min-max-vals: |
| 89 | + # All args and groups that are a part of this group are set here |
| 90 | + args: |
| 91 | + - minvals |
| 92 | + - maxvals |
| 93 | + # setting conflicts is done the same manner as setting 'args:' |
| 94 | + # |
| 95 | + # to make this group required, you could set 'required: true' but for |
| 96 | + # this example we won't do that. |
0 commit comments