diff options
author | Ryan <fauxpark@gmail.com> | 2020-11-02 19:41:01 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 00:41:01 -0800 |
commit | e69da2db2c59a8017f0c9dee9933dd508d22b356 (patch) | |
tree | 69dbe7f0731199331f6975df2ada13feab09eaeb /lib/python/qmk/cli/info.py | |
parent | dc40f00aafeea148d8998c594c4e414d87ee84a3 (diff) | |
download | qmk_firmware-e69da2db2c59a8017f0c9dee9933dd508d22b356.tar.gz qmk_firmware-e69da2db2c59a8017f0c9dee9933dd508d22b356.zip |
`qmk info`: Add `--ascii` flag (#10793)
* `qmk info`: Add `--ascii` flag
* Fix typo
* Force ASCII for Windows/MSYS2
* Make it gooder
* Remove redundant windows check
* ...And this too
* Make pytest work on Windows
Diffstat (limited to 'lib/python/qmk/cli/info.py')
-rwxr-xr-x | lib/python/qmk/cli/info.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py index 44ce1186a..9ab299a21 100755 --- a/lib/python/qmk/cli/info.py +++ b/lib/python/qmk/cli/info.py | |||
@@ -3,6 +3,7 @@ | |||
3 | Compile an info.json for a particular keyboard and pretty-print it. | 3 | Compile an info.json for a particular keyboard and pretty-print it. |
4 | """ | 4 | """ |
5 | import json | 5 | import json |
6 | import platform | ||
6 | 7 | ||
7 | from milc import cli | 8 | from milc import cli |
8 | 9 | ||
@@ -12,6 +13,8 @@ from qmk.keymap import locate_keymap | |||
12 | from qmk.info import info_json | 13 | from qmk.info import info_json |
13 | from qmk.path import is_keyboard | 14 | from qmk.path import is_keyboard |
14 | 15 | ||
16 | platform_id = platform.platform().lower() | ||
17 | |||
15 | ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop' | 18 | ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop' |
16 | COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz' | 19 | COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz' |
17 | 20 | ||
@@ -36,13 +39,13 @@ def show_keymap(kb_info_json, title_caps=True): | |||
36 | else: | 39 | else: |
37 | cli.echo('{fg_cyan}layer_%s{fg_reset}:', layer_num) | 40 | cli.echo('{fg_cyan}layer_%s{fg_reset}:', layer_num) |
38 | 41 | ||
39 | print(render_layout(kb_info_json['layouts'][layout_name]['layout'], layer)) | 42 | print(render_layout(kb_info_json['layouts'][layout_name]['layout'], cli.config.info.ascii, layer)) |
40 | 43 | ||
41 | 44 | ||
42 | def show_layouts(kb_info_json, title_caps=True): | 45 | def show_layouts(kb_info_json, title_caps=True): |
43 | """Render the layouts with info.json labels. | 46 | """Render the layouts with info.json labels. |
44 | """ | 47 | """ |
45 | for layout_name, layout_art in render_layouts(kb_info_json).items(): | 48 | for layout_name, layout_art in render_layouts(kb_info_json, cli.config.info.ascii).items(): |
46 | title = layout_name.title() if title_caps else layout_name | 49 | title = layout_name.title() if title_caps else layout_name |
47 | cli.echo('{fg_cyan}%s{fg_reset}:', title) | 50 | cli.echo('{fg_cyan}%s{fg_reset}:', title) |
48 | print(layout_art) # Avoid passing dirty data to cli.echo() | 51 | print(layout_art) # Avoid passing dirty data to cli.echo() |
@@ -69,7 +72,7 @@ def show_matrix(kb_info_json, title_caps=True): | |||
69 | else: | 72 | else: |
70 | cli.echo('{fg_blue}matrix_%s{fg_reset}:', layout_name) | 73 | cli.echo('{fg_blue}matrix_%s{fg_reset}:', layout_name) |
71 | 74 | ||
72 | print(render_layout(kb_info_json['layouts'][layout_name]['layout'], labels)) | 75 | print(render_layout(kb_info_json['layouts'][layout_name]['layout'], cli.config.info.ascii, labels)) |
73 | 76 | ||
74 | 77 | ||
75 | def print_friendly_output(kb_info_json): | 78 | def print_friendly_output(kb_info_json): |
@@ -124,6 +127,7 @@ def print_text_output(kb_info_json): | |||
124 | @cli.argument('-l', '--layouts', action='store_true', help='Render the layouts.') | 127 | @cli.argument('-l', '--layouts', action='store_true', help='Render the layouts.') |
125 | @cli.argument('-m', '--matrix', action='store_true', help='Render the layouts with matrix information.') | 128 | @cli.argument('-m', '--matrix', action='store_true', help='Render the layouts with matrix information.') |
126 | @cli.argument('-f', '--format', default='friendly', arg_only=True, help='Format to display the data in (friendly, text, json) (Default: friendly).') | 129 | @cli.argument('-f', '--format', default='friendly', arg_only=True, help='Format to display the data in (friendly, text, json) (Default: friendly).') |
130 | @cli.argument('--ascii', action='store_true', default='windows' in platform_id, help='Render layout box drawings in ASCII only.') | ||
127 | @cli.subcommand('Keyboard information.') | 131 | @cli.subcommand('Keyboard information.') |
128 | @automagic_keyboard | 132 | @automagic_keyboard |
129 | @automagic_keymap | 133 | @automagic_keymap |
@@ -132,7 +136,7 @@ def info(cli): | |||
132 | """ | 136 | """ |
133 | # Determine our keyboard(s) | 137 | # Determine our keyboard(s) |
134 | if not cli.config.info.keyboard: | 138 | if not cli.config.info.keyboard: |
135 | cli.log.error('Missing paramater: --keyboard') | 139 | cli.log.error('Missing parameter: --keyboard') |
136 | cli.subcommands['info'].print_help() | 140 | cli.subcommands['info'].print_help() |
137 | return False | 141 | return False |
138 | 142 | ||