diff options
Diffstat (limited to 'lib/python/qmk/cli/generate/version_h.py')
-rw-r--r-- | lib/python/qmk/cli/generate/version_h.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/python/qmk/cli/generate/version_h.py b/lib/python/qmk/cli/generate/version_h.py new file mode 100644 index 000000000..b8e52588c --- /dev/null +++ b/lib/python/qmk/cli/generate/version_h.py | |||
@@ -0,0 +1,28 @@ | |||
1 | """Used by the make system to generate version.h for use in code. | ||
2 | """ | ||
3 | from milc import cli | ||
4 | |||
5 | from qmk.commands import create_version_h | ||
6 | from qmk.path import normpath | ||
7 | |||
8 | |||
9 | @cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') | ||
10 | @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") | ||
11 | @cli.argument('--skip-git', arg_only=True, action='store_true', help='Skip Git operations') | ||
12 | @cli.argument('--skip-all', arg_only=True, action='store_true', help='Use placeholder values for all defines (implies --skip-git)') | ||
13 | @cli.subcommand('Used by the make system to generate version.h for use in code', hidden=True) | ||
14 | def generate_version_h(cli): | ||
15 | """Generates the version.h file. | ||
16 | """ | ||
17 | if cli.args.skip_all: | ||
18 | cli.args.skip_git = True | ||
19 | |||
20 | version_h = create_version_h(cli.args.skip_git, cli.args.skip_all) | ||
21 | |||
22 | if cli.args.output: | ||
23 | cli.args.output.write_text(version_h) | ||
24 | |||
25 | if not cli.args.quiet: | ||
26 | cli.log.info('Wrote version.h to %s.', cli.args.output) | ||
27 | else: | ||
28 | print(version_h) | ||