diff options
author | Nick Brassel <nick@tzarc.org> | 2023-05-29 06:17:24 +1000 |
---|---|---|
committer | Nick Brassel <nick@tzarc.org> | 2023-05-29 06:17:24 +1000 |
commit | 5024370dd0b441e86ace3089193e84c5b050d892 (patch) | |
tree | b661d5b154be987f9c3dba3a526b70e0b63f9fef /lib/python/qmk/cli/find.py | |
parent | 16767e4d59c2334fcd2d5e6556a68d5ff60ffd7b (diff) | |
parent | 8b1d86eabf399e82af7738fb675b9c74195d0f98 (diff) |
Merge branch 'develop'
Diffstat (limited to 'lib/python/qmk/cli/find.py')
-rw-r--r-- | lib/python/qmk/cli/find.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/python/qmk/cli/find.py b/lib/python/qmk/cli/find.py index b6f74380ab..2836eb8a54 100644 --- a/lib/python/qmk/cli/find.py +++ b/lib/python/qmk/cli/find.py @@ -11,13 +11,21 @@ from qmk.search import search_keymap_targets action='append', default=[], help= # noqa: `format-python` and `pytest` don't agree here. - "Filter the list of keyboards based on the supplied value in rules.mk. Matches info.json structure, and accepts the formats 'features.rgblight=true' or 'exists(matrix_pins.direct)'. May be passed multiple times, all filters need to match. Value may include wildcards such as '*' and '?'." # noqa: `format-python` and `pytest` don't agree here. + "Filter the list of keyboards based on their info.json data. Accepts the formats key=value, function(key), or function(key,value), eg. 'features.rgblight=true'. Valid functions are 'absent', 'contains', 'exists' and 'length'. May be passed multiple times; all filters need to match. Value may include wildcards such as '*' and '?'." # noqa: `format-python` and `pytest` don't agree here. ) +@cli.argument('-p', '--print', arg_only=True, action='append', default=[], help="For each matched target, print the value of the supplied info.json key. May be passed multiple times.") @cli.argument('-km', '--keymap', type=str, default='default', help="The keymap name to build. Default is 'default'.") @cli.subcommand('Find builds which match supplied search criteria.') def find(cli): """Search through all keyboards and keymaps for a given search criteria. """ - targets = search_keymap_targets(cli.args.keymap, cli.args.filter) - for target in targets: - print(f'{target[0]}:{target[1]}') + + if len(cli.args.filter) == 0 and len(cli.args.print) > 0: + cli.log.warning('No filters supplied -- keymaps not parsed, unable to print requested values.') + + targets = search_keymap_targets(cli.args.keymap, cli.args.filter, cli.args.print) + for keyboard, keymap, print_vals in targets: + print(f'{keyboard}:{keymap}') + + for key, val in print_vals: + print(f' {key}={val}') |