logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

find.py (1627B)


  1. """Command to search through all keyboards and keymaps for a given search criteria.
  2. """
  3. import os
  4. from milc import cli
  5. from qmk.search import filter_help, search_keymap_targets
  6. from qmk.util import maybe_exit_config
  7. @cli.argument(
  8. '-f',
  9. '--filter',
  10. arg_only=True,
  11. action='append',
  12. default=[],
  13. help= # noqa: `format-python` and `pytest` don't agree here.
  14. f"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 {filter_help()}. 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.
  15. )
  16. @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.")
  17. @cli.argument('-km', '--keymap', type=str, default='default', help="The keymap name to build. Default is 'default'.")
  18. @cli.subcommand('Find builds which match supplied search criteria.')
  19. def find(cli):
  20. """Search through all keyboards and keymaps for a given search criteria.
  21. """
  22. os.environ.setdefault('SKIP_SCHEMA_VALIDATION', '1')
  23. maybe_exit_config(should_exit=False, should_reraise=True)
  24. targets = search_keymap_targets([('all', cli.config.find.keymap)], cli.args.filter)
  25. for target in sorted(targets, key=lambda t: (t.keyboard, t.keymap)):
  26. print(f'{target}')
  27. for key in cli.args.print:
  28. print(f' {key}={target.dotty.get(key, None)}')