You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.0 KiB

Configuration system for CLI (#6708) * Rework how bin/qmk handles subcommands * qmk config wip * Code to show all configs * Fully working `qmk config` command * Mark some CLI arguments so they don't pollute the config file * Fleshed out config support, nicer subcommand support * sync with installable cli * pyformat * Add a test for subcommand_modules * Documentation for the `qmk config` command * split config_token on space so qmk config is more predictable * Rework how subcommands are imported * Document `arg_only` * Document deleting from CLI * Document how multiple operations work * Add cli config to the doc index * Add tests for the cli commands * Make running the tests more reliable * Be more selective about building all default keymaps * Update new-keymap to fit the new subcommand style * Add documentation about writing CLI scripts * Document new-keyboard * Update docs/cli_configuration.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Address yan's comments. * Apply suggestions from code review suggestions from @noahfrederick Co-Authored-By: Noah Frederick <code@noahfrederick.com> * Apply suggestions from code review Co-Authored-By: Noah Frederick <code@noahfrederick.com> * Remove pip3 from the test runner
4 years ago
Configuration system for CLI (#6708) * Rework how bin/qmk handles subcommands * qmk config wip * Code to show all configs * Fully working `qmk config` command * Mark some CLI arguments so they don't pollute the config file * Fleshed out config support, nicer subcommand support * sync with installable cli * pyformat * Add a test for subcommand_modules * Documentation for the `qmk config` command * split config_token on space so qmk config is more predictable * Rework how subcommands are imported * Document `arg_only` * Document deleting from CLI * Document how multiple operations work * Add cli config to the doc index * Add tests for the cli commands * Make running the tests more reliable * Be more selective about building all default keymaps * Update new-keymap to fit the new subcommand style * Add documentation about writing CLI scripts * Document new-keyboard * Update docs/cli_configuration.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Address yan's comments. * Apply suggestions from code review suggestions from @noahfrederick Co-Authored-By: Noah Frederick <code@noahfrederick.com> * Apply suggestions from code review Co-Authored-By: Noah Frederick <code@noahfrederick.com> * Remove pip3 from the test runner
4 years ago
Configuration system for CLI (#6708) * Rework how bin/qmk handles subcommands * qmk config wip * Code to show all configs * Fully working `qmk config` command * Mark some CLI arguments so they don't pollute the config file * Fleshed out config support, nicer subcommand support * sync with installable cli * pyformat * Add a test for subcommand_modules * Documentation for the `qmk config` command * split config_token on space so qmk config is more predictable * Rework how subcommands are imported * Document `arg_only` * Document deleting from CLI * Document how multiple operations work * Add cli config to the doc index * Add tests for the cli commands * Make running the tests more reliable * Be more selective about building all default keymaps * Update new-keymap to fit the new subcommand style * Add documentation about writing CLI scripts * Document new-keyboard * Update docs/cli_configuration.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update docs/cli_development.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Address yan's comments. * Apply suggestions from code review suggestions from @noahfrederick Co-Authored-By: Noah Frederick <code@noahfrederick.com> * Apply suggestions from code review Co-Authored-By: Noah Frederick <code@noahfrederick.com> * Remove pip3 from the test runner
4 years ago
  1. # QMK CLI Configuration
  2. This document explains how `qmk config` works.
  3. # Introduction
  4. Configuration for the QMK CLI is a key/value system. Each key consists of a subcommand and an argument name separated by a period. This allows for a straightforward and direct translation between config keys and the arguments they set.
  5. ## Simple Example
  6. As an example let's look at the command `qmk compile --keyboard clueboard/66/rev4 --keymap default`.
  7. There are two command line arguments that could be read from configuration instead:
  8. * `compile.keyboard`
  9. * `compile.keymap`
  10. Let's set these now:
  11. ```
  12. $ qmk config compile.keyboard=clueboard/66/rev4 compile.keymap=default
  13. compile.keyboard: None -> clueboard/66/rev4
  14. compile.keymap: None -> default
  15. Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
  16. ```
  17. Now I can run `qmk compile` without specifying my keyboard and keymap each time.
  18. ## Setting User Defaults
  19. Sometimes you want to share a setting between multiple commands. For example, multiple commands take the argument `--keyboard`. Rather than setting this value for every command you can set a user value which will be used by any command that takes that argument.
  20. Example:
  21. ```
  22. $ qmk config user.keyboard=clueboard/66/rev4 user.keymap=default
  23. user.keyboard: None -> clueboard/66/rev4
  24. user.keymap: None -> default
  25. Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
  26. ```
  27. # CLI Documentation (`qmk config`)
  28. The `qmk config` command is used to interact with the underlying configuration. When run with no argument it shows the current configuration. When arguments are supplied they are assumed to be configuration tokens, which are strings containing no spaces with the following form:
  29. <subcommand|general|default>[.<key>][=<value>]
  30. ## Setting Configuration Values
  31. You can set configuration values by putting an equal sign (=) into your config key. The key must always be the full `<section>.<key>` form.
  32. Example:
  33. ```
  34. $ qmk config default.keymap=default
  35. default.keymap: None -> default
  36. Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
  37. ```
  38. ## Reading Configuration Values
  39. You can read configuration values for the entire configuration, a single key, or for an entire section. You can also specify multiple keys to display more than one value.
  40. ### Entire Configuration Example
  41. qmk config
  42. ### Whole Section Example
  43. qmk config compile
  44. ### Single Key Example
  45. qmk config compile.keyboard
  46. ### Multiple Keys Example
  47. qmk config user compile.keyboard compile.keymap
  48. ## Deleting Configuration Values
  49. You can delete a configuration value by setting it to the special string `None`.
  50. Example:
  51. ```
  52. $ qmk config default.keymap=None
  53. default.keymap: default -> None
  54. Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
  55. ```
  56. ## Multiple Operations
  57. You can combine multiple read and write operations into a single command. They will be executed and displayed in order:
  58. ```
  59. $ qmk config compile default.keymap=default compile.keymap=None
  60. compile.keymap=skully
  61. compile.keyboard=clueboard/66_hotswap/gen1
  62. default.keymap: None -> default
  63. compile.keymap: skully -> None
  64. Ψ Wrote configuration to '/Users/example/Library/Application Support/qmk/qmk.ini'
  65. ```
  66. # User Configuration Options
  67. | Key | Default Value | Description |
  68. |-----|---------------|-------------|
  69. | user.keyboard | None | The keyboard path (Example: `clueboard/66/rev4`) |
  70. | user.keymap | None | The keymap name (Example: `default`) |
  71. | user.name | None | The user's GitHub username. |
  72. # All Configuration Options
  73. | Key | Default Value | Description |
  74. |-----|---------------|-------------|
  75. | compile.keyboard | None | The keyboard path (Example: `clueboard/66/rev4`) |
  76. | compile.keymap | None | The keymap name (Example: `default`) |
  77. | hello.name | None | The name to greet when run. |
  78. | new_keyboard.keyboard | None | The keyboard path (Example: `clueboard/66/rev4`) |
  79. | new_keyboard.keymap | None | The keymap name (Example: `default`) |