diff options
author | QMK Bot <hello@qmk.fm> | 2020-12-29 19:35:24 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2020-12-29 19:35:24 +0000 |
commit | 7b7763469bb8cc0091d02f1f5a5e77d70d7666cd (patch) | |
tree | 8480a7cb9573d22d7ecbcd28c9d0cb49b5ac803b /lib/python/qmk/cli/c2json.py | |
parent | 9748b6b847d9c184db6efd660ee8b343a4bf7485 (diff) | |
parent | 221d8fd8669ff528bfedd01f41486f5298d960e1 (diff) |
Merge remote-tracking branch 'origin/master' into develop
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 8c8bd1f57e..2b3bb774f7 100644 --- a/lib/python/qmk/cli/c2json.py +++ b/lib/python/qmk/cli/c2json.py @@ -1,7 +1,6 @@ """Generate a keymap.json from a keymap.c file. """ import json -import sys from milc import cli @@ -21,19 +20,14 @@ def c2json(cli): 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. """ - cli.args.filename = qmk.path.normpath(cli.args.filename) + if cli.args.filename != '-': + cli.args.filename = qmk.path.normpath(cli.args.filename) - # Error checking - if not cli.args.filename.exists(): - cli.log.error('C file does not exist!') - cli.print_usage() - exit(1) - - if str(cli.args.filename) == '-': - # TODO(skullydazed/anyone): Read file contents from STDIN - cli.log.error('Reading from STDIN is not (yet) supported.') - cli.print_usage() - exit(1) + # Error checking + if not cli.args.filename.exists(): + cli.log.error('C file does not exist!') + cli.print_usage() + return False # Environment processing if cli.args.output == ('-'): @@ -47,7 +41,7 @@ def c2json(cli): keymap_json = qmk.keymap.generate_json(keymap_json['keymap'], keymap_json['keyboard'], keymap_json['layout'], keymap_json['layers']) except KeyError: cli.log.error('Something went wrong. Try to use --no-cpp.') - sys.exit(1) + return False if cli.args.output: cli.args.output.parent.mkdir(parents=True, exist_ok=True) |