aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/info.py
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2020-11-02 19:41:01 +1100
committerGitHub <noreply@github.com>2020-11-02 00:41:01 -0800
commite69da2db2c59a8017f0c9dee9933dd508d22b356 (patch)
tree69dbe7f0731199331f6975df2ada13feab09eaeb /lib/python/qmk/cli/info.py
parentdc40f00aafeea148d8998c594c4e414d87ee84a3 (diff)
downloadqmk_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-xlib/python/qmk/cli/info.py12
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 @@
3Compile an info.json for a particular keyboard and pretty-print it. 3Compile an info.json for a particular keyboard and pretty-print it.
4""" 4"""
5import json 5import json
6import platform
6 7
7from milc import cli 8from milc import cli
8 9
@@ -12,6 +13,8 @@ from qmk.keymap import locate_keymap
12from qmk.info import info_json 13from qmk.info import info_json
13from qmk.path import is_keyboard 14from qmk.path import is_keyboard
14 15
16platform_id = platform.platform().lower()
17
15ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop' 18ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop'
16COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz' 19COL_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
42def show_layouts(kb_info_json, title_caps=True): 45def 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
75def print_friendly_output(kb_info_json): 78def 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