summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-06-27 02:29:02 +1000
committerGitHub <noreply@github.com>2021-06-27 02:29:02 +1000
commitbbe43a91ebf193bbc8c09ba59209b0524367e68c (patch)
treeb4b1cac772b2601154153a39d2173334cdf363d9 /lib/python/qmk/cli
parent546f5f2c4f38a4abf934e3df84985feca61f90c7 (diff)
downloadqmk_firmware-bbe43a91ebf193bbc8c09ba59209b0524367e68c.tar.gz
qmk_firmware-bbe43a91ebf193bbc8c09ba59209b0524367e68c.zip
CLI: Add subcommand to generate version.h (#13151)
Diffstat (limited to 'lib/python/qmk/cli')
-rw-r--r--lib/python/qmk/cli/__init__.py1
-rw-r--r--lib/python/qmk/cli/generate/version_h.py28
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index 7f5e0a1fa6..2c3c9c4211 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -49,6 +49,7 @@ subcommands = [
'qmk.cli.generate.layouts',
'qmk.cli.generate.rgb_breathe_table',
'qmk.cli.generate.rules_mk',
+ 'qmk.cli.generate.version_h',
'qmk.cli.hello',
'qmk.cli.info',
'qmk.cli.json2c',
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 0000000000..b8e52588c4
--- /dev/null
+++ b/lib/python/qmk/cli/generate/version_h.py
@@ -0,0 +1,28 @@
+"""Used by the make system to generate version.h for use in code.
+"""
+from milc import cli
+
+from qmk.commands import create_version_h
+from qmk.path import normpath
+
+
+@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
+@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
+@cli.argument('--skip-git', arg_only=True, action='store_true', help='Skip Git operations')
+@cli.argument('--skip-all', arg_only=True, action='store_true', help='Use placeholder values for all defines (implies --skip-git)')
+@cli.subcommand('Used by the make system to generate version.h for use in code', hidden=True)
+def generate_version_h(cli):
+ """Generates the version.h file.
+ """
+ if cli.args.skip_all:
+ cli.args.skip_git = True
+
+ version_h = create_version_h(cli.args.skip_git, cli.args.skip_all)
+
+ if cli.args.output:
+ cli.args.output.write_text(version_h)
+
+ if not cli.args.quiet:
+ cli.log.info('Wrote version.h to %s.', cli.args.output)
+ else:
+ print(version_h)