summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/generate/dfu_header.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/cli/generate/dfu_header.py')
-rw-r--r--lib/python/qmk/cli/generate/dfu_header.py18
1 files changed, 4 insertions, 14 deletions
diff --git a/lib/python/qmk/cli/generate/dfu_header.py b/lib/python/qmk/cli/generate/dfu_header.py
index 7fb585fc7d..e873117387 100644
--- a/lib/python/qmk/cli/generate/dfu_header.py
+++ b/lib/python/qmk/cli/generate/dfu_header.py
@@ -7,6 +7,8 @@ from qmk.decorators import automagic_keyboard
from qmk.info import info_json
from qmk.path import is_keyboard, normpath
from qmk.keyboard import keyboard_completer
+from qmk.commands import dump_lines
+from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
@@ -30,7 +32,7 @@ def generate_dfu_header(cli):
# Build the Keyboard.h file.
kb_info_json = dotty(info_json(cli.config.generate_dfu_header.keyboard))
- keyboard_h_lines = ['/* This file was generated by `qmk generate-dfu-header`. Do not edit or copy.', ' */', '', '#pragma once']
+ keyboard_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once']
keyboard_h_lines.append(f'#define MANUFACTURER {kb_info_json["manufacturer"]}')
keyboard_h_lines.append(f'#define PRODUCT {kb_info_json["keyboard_name"]} Bootloader')
@@ -45,16 +47,4 @@ def generate_dfu_header(cli):
keyboard_h_lines.append(f'#define QMK_SPEAKER {kb_info_json["qmk_lufa_bootloader.speaker"]}')
# Show the results
- keyboard_h = '\n'.join(keyboard_h_lines)
-
- if cli.args.output:
- 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(keyboard_h)
-
- if not cli.args.quiet:
- cli.log.info('Wrote Keyboard.h to %s.', cli.args.output)
-
- else:
- print(keyboard_h)
+ dump_lines(cli.args.output, keyboard_h_lines, cli.args.quiet)