diff options
author | skullydazed <skullydazed@users.noreply.github.com> | 2020-04-18 13:00:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-18 22:00:56 +0200 |
commit | 66d94dc22af4fccae2af073c512662ce7eba7d98 (patch) | |
tree | a720968b0f1951cc2ec920da373701d308f04d88 /docs/cli_development.md | |
parent | 5a8f59503e41923030249561e9ef56be62de3efa (diff) | |
download | qmk_firmware-66d94dc22af4fccae2af073c512662ce7eba7d98.tar.gz qmk_firmware-66d94dc22af4fccae2af073c512662ce7eba7d98.zip |
Move everything to Python 3.6 (#8835)
Diffstat (limited to 'docs/cli_development.md')
-rw-r--r-- | docs/cli_development.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/cli_development.md b/docs/cli_development.md index 2a967de4a..af86686c0 100644 --- a/docs/cli_development.md +++ b/docs/cli_development.md | |||
@@ -44,7 +44,7 @@ def hello(cli): | |||
44 | 44 | ||
45 | First we import the `cli` object from `milc`. This is how we interact with the user and control the script's behavior. We use `@cli.argument()` to define a command line flag, `--name`. This also creates a configuration variable named `hello.name` (and the corresponding `user.name`) which the user can set so they don't have to specify the argument. The `cli.subcommand()` decorator designates this function as a subcommand. The name of the subcommand will be taken from the name of the function. | 45 | First we import the `cli` object from `milc`. This is how we interact with the user and control the script's behavior. We use `@cli.argument()` to define a command line flag, `--name`. This also creates a configuration variable named `hello.name` (and the corresponding `user.name`) which the user can set so they don't have to specify the argument. The `cli.subcommand()` decorator designates this function as a subcommand. The name of the subcommand will be taken from the name of the function. |
46 | 46 | ||
47 | Once inside our function we find a typical "Hello, World!" program. We use `cli.log` to access the underlying [Logger Object](https://docs.python.org/3.5/library/logging.html#logger-objects), whose behavior is user controllable. We also access the value for name supplied by the user as `cli.config.hello.name`. The value for `cli.config.hello.name` will be determined by looking at the `--name` argument supplied by the user, if not provided it will use the value in the `qmk.ini` config file, and if neither of those is provided it will fall back to the default supplied in the `cli.argument()` decorator. | 47 | Once inside our function we find a typical "Hello, World!" program. We use `cli.log` to access the underlying [Logger Object](https://docs.python.org/3.6/library/logging.html#logger-objects), whose behavior is user controllable. We also access the value for name supplied by the user as `cli.config.hello.name`. The value for `cli.config.hello.name` will be determined by looking at the `--name` argument supplied by the user, if not provided it will use the value in the `qmk.ini` config file, and if neither of those is provided it will fall back to the default supplied in the `cli.argument()` decorator. |
48 | 48 | ||
49 | # User Interaction | 49 | # User Interaction |
50 | 50 | ||
@@ -56,13 +56,13 @@ There are two main methods for outputting text in a subcommand- `cli.log` and `c | |||
56 | 56 | ||
57 | You can use special tokens to colorize your text, to make it easier to understand the output of your program. See [Colorizing Text](#colorizing-text) below. | 57 | You can use special tokens to colorize your text, to make it easier to understand the output of your program. See [Colorizing Text](#colorizing-text) below. |
58 | 58 | ||
59 | Both of these methods support built-in string formatting using python's [printf style string format operations](https://docs.python.org/3.5/library/stdtypes.html#old-string-formatting). You can use tokens such as `%s` and `%d` within your text strings then pass the values as arguments. See our Hello, World program above for an example. | 59 | Both of these methods support built-in string formatting using python's [printf style string format operations](https://docs.python.org/3.6/library/stdtypes.html#old-string-formatting). You can use tokens such as `%s` and `%d` within your text strings then pass the values as arguments. See our Hello, World program above for an example. |
60 | 60 | ||
61 | You should never use the format operator (`%`) directly, always pass values as arguments. | 61 | You should never use the format operator (`%`) directly, always pass values as arguments. |
62 | 62 | ||
63 | ### Logging (`cli.log`) | 63 | ### Logging (`cli.log`) |
64 | 64 | ||
65 | The `cli.log` object gives you access to a [Logger Object](https://docs.python.org/3.5/library/logging.html#logger-objects). We have configured our log output to show the user a nice emoji for each log level (or the log level name if their terminal does not support unicode.) This way the user can tell at a glance which messages are most important when something goes wrong. | 65 | The `cli.log` object gives you access to a [Logger Object](https://docs.python.org/3.6/library/logging.html#logger-objects). We have configured our log output to show the user a nice emoji for each log level (or the log level name if their terminal does not support unicode.) This way the user can tell at a glance which messages are most important when something goes wrong. |
66 | 66 | ||
67 | The default log level is `INFO`. If the user runs `qmk -v <subcommand>` the default log level will be set to `DEBUG`. | 67 | The default log level is `INFO`. If the user runs `qmk -v <subcommand>` the default log level will be set to `DEBUG`. |
68 | 68 | ||