summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2023-05-20 22:15:05 +1000
committerGitHub <noreply@github.com>2023-05-20 22:15:05 +1000
commit6d90fa2300b463f5cc6920022a445d5ed217124c (patch)
tree2b0ae6329af789e81ba5d7313b752e5e828493e0 /lib/python/qmk/cli
parent102c42b14bc79a178d16ae5217d739490a312ea4 (diff)
`qmk format-json`: Expose full key path and respect `sort_keys` (#20836)
Diffstat (limited to 'lib/python/qmk/cli')
-rw-r--r--lib/python/qmk/cli/c2json.py2
-rwxr-xr-xlib/python/qmk/cli/format/json.py2
-rwxr-xr-xlib/python/qmk/cli/generate/info_json.py2
-rwxr-xr-xlib/python/qmk/cli/info.py2
-rw-r--r--lib/python/qmk/cli/migrate.py2
-rw-r--r--lib/python/qmk/cli/new/keyboard.py2
-rwxr-xr-xlib/python/qmk/cli/via2json.py2
7 files changed, 7 insertions, 7 deletions
diff --git a/lib/python/qmk/cli/c2json.py b/lib/python/qmk/cli/c2json.py
index 43110a9387..7f6aca070a 100644
--- a/lib/python/qmk/cli/c2json.py
+++ b/lib/python/qmk/cli/c2json.py
@@ -57,7 +57,7 @@ def c2json(cli):
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
- cli.args.output.write_text(json.dumps(keymap_json, cls=InfoJSONEncoder))
+ cli.args.output.write_text(json.dumps(keymap_json, cls=InfoJSONEncoder, sort_keys=True))
if not cli.args.quiet:
cli.log.info('Wrote keymap to %s.', cli.args.output)
diff --git a/lib/python/qmk/cli/format/json.py b/lib/python/qmk/cli/format/json.py
index 19d504491f..058b613294 100755
--- a/lib/python/qmk/cli/format/json.py
+++ b/lib/python/qmk/cli/format/json.py
@@ -62,4 +62,4 @@ def format_json(cli):
json_file['layers'][layer_num] = current_layer
# Display the results
- print(json.dumps(json_file, cls=json_encoder))
+ print(json.dumps(json_file, cls=json_encoder, sort_keys=True))
diff --git a/lib/python/qmk/cli/generate/info_json.py b/lib/python/qmk/cli/generate/info_json.py
index 0dc80f10cc..08c294146b 100755
--- a/lib/python/qmk/cli/generate/info_json.py
+++ b/lib/python/qmk/cli/generate/info_json.py
@@ -76,7 +76,7 @@ def generate_info_json(cli):
# Build the info.json file
kb_info_json = info_json(cli.config.generate_info_json.keyboard)
strip_info_json(kb_info_json)
- info_json_text = json.dumps(kb_info_json, indent=4, cls=InfoJSONEncoder)
+ info_json_text = json.dumps(kb_info_json, indent=4, cls=InfoJSONEncoder, sort_keys=True)
if cli.args.output:
# Write to a file
diff --git a/lib/python/qmk/cli/info.py b/lib/python/qmk/cli/info.py
index 839139346c..cfb73ce1fd 100755
--- a/lib/python/qmk/cli/info.py
+++ b/lib/python/qmk/cli/info.py
@@ -200,7 +200,7 @@ def info(cli):
# Output in the requested format
if cli.args.format == 'json':
- print(json.dumps(kb_info_json, cls=InfoJSONEncoder))
+ print(json.dumps(kb_info_json, cls=InfoJSONEncoder, sort_keys=True))
return True
elif cli.args.format == 'text':
print_dotted_output(kb_info_json)
diff --git a/lib/python/qmk/cli/migrate.py b/lib/python/qmk/cli/migrate.py
index 4164f9c8ad..c1b1ad1ea9 100644
--- a/lib/python/qmk/cli/migrate.py
+++ b/lib/python/qmk/cli/migrate.py
@@ -75,7 +75,7 @@ def migrate(cli):
# Finally write out updated info.json
cli.log.info(f' Updating {target_info}')
- target_info.write_text(json.dumps(info_data.to_dict(), cls=InfoJSONEncoder))
+ target_info.write_text(json.dumps(info_data.to_dict(), cls=InfoJSONEncoder, sort_keys=True))
cli.log.info(f'{{fg_green}}Migration of keyboard {{fg_cyan}}{cli.args.keyboard}{{fg_green}} complete!{{fg_reset}}')
cli.log.info(f"Verify build with {{fg_yellow}}qmk compile -kb {cli.args.keyboard} -km default{{fg_reset}}.")
diff --git a/lib/python/qmk/cli/new/keyboard.py b/lib/python/qmk/cli/new/keyboard.py
index cdd3919168..ce956d0ce1 100644
--- a/lib/python/qmk/cli/new/keyboard.py
+++ b/lib/python/qmk/cli/new/keyboard.py
@@ -102,7 +102,7 @@ def augment_community_info(src, dest):
item["matrix"] = [int(item["y"]), int(item["x"])]
# finally write out the updated info.json
- dest.write_text(json.dumps(info, cls=InfoJSONEncoder))
+ dest.write_text(json.dumps(info, cls=InfoJSONEncoder, sort_keys=True))
def _question(*args, **kwargs):
diff --git a/lib/python/qmk/cli/via2json.py b/lib/python/qmk/cli/via2json.py
index 6edc9dfbe5..77823b5d9d 100755
--- a/lib/python/qmk/cli/via2json.py
+++ b/lib/python/qmk/cli/via2json.py
@@ -141,5 +141,5 @@ def via2json(cli):
# Generate the keymap.json
keymap_json = generate_json(cli.args.keymap, cli.args.keyboard, keymap_layout, keymap_data, macro_data)
- keymap_lines = [json.dumps(keymap_json, cls=KeymapJSONEncoder)]
+ keymap_lines = [json.dumps(keymap_json, cls=KeymapJSONEncoder, sort_keys=True)]
dump_lines(cli.args.output, keymap_lines, cli.args.quiet)