diff options
Diffstat (limited to 'lib/python/qmk/cli/c2json.py')
-rw-r--r-- | lib/python/qmk/cli/c2json.py | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/python/qmk/cli/c2json.py b/lib/python/qmk/cli/c2json.py index 8c8bd1f57..2b3bb774f 100644 --- a/lib/python/qmk/cli/c2json.py +++ b/lib/python/qmk/cli/c2json.py | |||
@@ -1,7 +1,6 @@ | |||
1 | """Generate a keymap.json from a keymap.c file. | 1 | """Generate a keymap.json from a keymap.c file. |
2 | """ | 2 | """ |
3 | import json | 3 | import json |
4 | import sys | ||
5 | 4 | ||
6 | from milc import cli | 5 | from milc import cli |
7 | 6 | ||
@@ -21,19 +20,14 @@ def c2json(cli): | |||
21 | 20 | ||
22 | This command uses the `qmk.keymap` module to generate a keymap.json from a keymap.c file. The generated keymap is written to stdout, or to a file if -o is provided. | 21 | This command uses the `qmk.keymap` module to generate a keymap.json from a keymap.c file. The generated keymap is written to stdout, or to a file if -o is provided. |
23 | """ | 22 | """ |
24 | cli.args.filename = qmk.path.normpath(cli.args.filename) | 23 | if cli.args.filename != '-': |
24 | cli.args.filename = qmk.path.normpath(cli.args.filename) | ||
25 | 25 | ||
26 | # Error checking | 26 | # Error checking |
27 | if not cli.args.filename.exists(): | 27 | if not cli.args.filename.exists(): |
28 | cli.log.error('C file does not exist!') | 28 | cli.log.error('C file does not exist!') |
29 | cli.print_usage() | 29 | cli.print_usage() |
30 | exit(1) | 30 | return False |
31 | |||
32 | if str(cli.args.filename) == '-': | ||
33 | # TODO(skullydazed/anyone): Read file contents from STDIN | ||
34 | cli.log.error('Reading from STDIN is not (yet) supported.') | ||
35 | cli.print_usage() | ||
36 | exit(1) | ||
37 | 31 | ||
38 | # Environment processing | 32 | # Environment processing |
39 | if cli.args.output == ('-'): | 33 | if cli.args.output == ('-'): |
@@ -47,7 +41,7 @@ def c2json(cli): | |||
47 | keymap_json = qmk.keymap.generate_json(keymap_json['keymap'], keymap_json['keyboard'], keymap_json['layout'], keymap_json['layers']) | 41 | keymap_json = qmk.keymap.generate_json(keymap_json['keymap'], keymap_json['keyboard'], keymap_json['layout'], keymap_json['layers']) |
48 | except KeyError: | 42 | except KeyError: |
49 | cli.log.error('Something went wrong. Try to use --no-cpp.') | 43 | cli.log.error('Something went wrong. Try to use --no-cpp.') |
50 | sys.exit(1) | 44 | return False |
51 | 45 | ||
52 | if cli.args.output: | 46 | if cli.args.output: |
53 | cli.args.output.parent.mkdir(parents=True, exist_ok=True) | 47 | cli.args.output.parent.mkdir(parents=True, exist_ok=True) |