aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/cli')
-rw-r--r--lib/python/qmk/cli/__init__.py4
-rw-r--r--lib/python/qmk/cli/new/keyboard.py74
-rw-r--r--lib/python/qmk/cli/painter/convert_graphics.py4
-rw-r--r--lib/python/qmk/cli/painter/make_font.py4
4 files changed, 48 insertions, 38 deletions
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py
index 0baf19a629..2d63dfb447 100644
--- a/lib/python/qmk/cli/__init__.py
+++ b/lib/python/qmk/cli/__init__.py
@@ -207,8 +207,8 @@ def _eprint(errmsg):
# Ubuntu 24.04: 3.12
# void: 3.12
-if sys.version_info[0] != 3 or sys.version_info[1] < 7:
- _eprint('Error: Your Python is too old! Please upgrade to Python 3.7 or later.')
+if sys.version_info[0] != 3 or sys.version_info[1] < 9:
+ _eprint('Error: Your Python is too old! Please upgrade to Python 3.9 or later.')
exit(127)
milc_version = __VERSION__.split('.')
diff --git a/lib/python/qmk/cli/new/keyboard.py b/lib/python/qmk/cli/new/keyboard.py
index b84b130f8e..bd02acf9c8 100644
--- a/lib/python/qmk/cli/new/keyboard.py
+++ b/lib/python/qmk/cli/new/keyboard.py
@@ -8,7 +8,7 @@ from pathlib import Path
from dotty_dict import dotty
from milc import cli
-from milc.questions import choice, question
+from milc.questions import choice, question, yesno
from qmk.git import git_get_username
from qmk.json_schema import load_jsonschema
@@ -131,60 +131,70 @@ def _question(*args, **kwargs):
return ret
-def prompt_keyboard():
- prompt = """{fg_yellow}Name Your Keyboard Project{style_reset_all}
-For more infomation, see:
-https://docs.qmk.fm/hardware_keyboard_guidelines#naming-your-keyboard-project
+def prompt_heading_subheading(heading, subheading):
+ cli.log.info(f"{{fg_yellow}}{heading}{{style_reset_all}}")
+ cli.log.info(subheading)
+
-Keyboard Name? """
+def prompt_keyboard():
+ prompt_heading_subheading("Name Your Keyboard Project", """For more information, see:
+https://docs.qmk.fm/hardware_keyboard_guidelines#naming-your-keyboard-project""")
errmsg = 'Keyboard already exists! Please choose a different name:'
- return _question(prompt, reprompt=errmsg, validate=lambda x: not keyboard(x).exists())
+ return _question("Keyboard Name?", reprompt=errmsg, validate=lambda x: not keyboard(x).exists())
def prompt_user():
- prompt = """
-{fg_yellow}Attribution{style_reset_all}
-Used for maintainer, copyright, etc
+ prompt_heading_subheading("Attribution", "Used for maintainer, copyright, etc.")
-Your GitHub Username? """
- return question(prompt, default=git_get_username())
+ return question("Your GitHub Username?", default=git_get_username())
def prompt_name(def_name):
- prompt = """
-{fg_yellow}More Attribution{style_reset_all}
-Used for maintainer, copyright, etc
+ prompt_heading_subheading("More Attribution", "Used for maintainer, copyright, etc.")
-Your Real Name? """
- return question(prompt, default=def_name)
+ return question("Your Real Name?", default=def_name)
def prompt_layout():
- prompt = """
-{fg_yellow}Pick Base Layout{style_reset_all}
-As a starting point, one of the common layouts can be used to bootstrap the process
+ prompt_heading_subheading("Pick Base Layout", """As a starting point, one of the common layouts can be used to
+bootstrap the process""")
-Default Layout? """
# avoid overwhelming user - remove some?
filtered_layouts = [x for x in available_layouts if not any(xs in x for xs in ['_split', '_blocker', '_tsangan', '_f13'])]
filtered_layouts.append("none of the above")
- return choice(prompt, filtered_layouts, default=len(filtered_layouts) - 1)
+ return choice("Default Layout?", filtered_layouts, default=len(filtered_layouts) - 1)
+
+
+def prompt_mcu_type():
+ prompt_heading_subheading(
+ "What Powers Your Project", """Is your board using a separate development board, such as a Pro Micro,
+or is the microcontroller integrated onto the PCB?
+
+For more information, see:
+https://docs.qmk.fm/compatible_microcontrollers"""
+ )
+
+ return yesno("Using a Development Board?")
+
+
+def prompt_dev_board():
+ prompt_heading_subheading("Select Development Board", """For more information, see:
+https://docs.qmk.fm/compatible_microcontrollers""")
+
+ return choice("Development Board?", dev_boards, default=dev_boards.index("promicro"))
def prompt_mcu():
- prompt = """
-{fg_yellow}What Powers Your Project{style_reset_all}
-For more infomation, see:
-https://docs.qmk.fm/#/compatible_microcontrollers
+ prompt_heading_subheading("Select Microcontroller", """For more information, see:
+https://docs.qmk.fm/compatible_microcontrollers""")
-MCU? """
# remove any options strictly used for compatibility
- filtered_mcu = [x for x in (dev_boards + mcu_types) if not any(xs in x for xs in ['cortex', 'unknown'])]
+ filtered_mcu = [x for x in mcu_types if not any(xs in x for xs in ['cortex', 'unknown'])]
- return choice(prompt, filtered_mcu, default=filtered_mcu.index("atmega32u4"))
+ return choice("Microcontroller?", filtered_mcu, default=filtered_mcu.index("atmega32u4"))
@cli.argument('-kb', '--keyboard', help='Specify the name for the new keyboard directory', arg_only=True, type=keyboard_name)
@@ -211,7 +221,11 @@ def new_keyboard(cli):
user_name = cli.config.new_keyboard.name if cli.config.new_keyboard.name else prompt_user()
real_name = cli.args.realname or cli.config.new_keyboard.name if cli.args.realname or cli.config.new_keyboard.name else prompt_name(user_name)
default_layout = cli.args.layout if cli.args.layout else prompt_layout()
- mcu = cli.args.type if cli.args.type else prompt_mcu()
+
+ if cli.args.type:
+ mcu = cli.args.type
+ else:
+ mcu = prompt_dev_board() if prompt_mcu_type() else prompt_mcu()
config = {}
if mcu in dev_boards:
diff --git a/lib/python/qmk/cli/painter/convert_graphics.py b/lib/python/qmk/cli/painter/convert_graphics.py
index 553c26aa5d..f74d655fd5 100644
--- a/lib/python/qmk/cli/painter/convert_graphics.py
+++ b/lib/python/qmk/cli/painter/convert_graphics.py
@@ -60,9 +60,7 @@ def painter_convert_graphics(cli):
return
# Work out the text substitutions for rendering the output data
- args_str = " ".join((f"--{arg} {getattr(cli.args, arg.replace('-', '_'))}" for arg in ["input", "output", "format", "no-rle", "no-deltas"]))
- command = f"qmk painter-convert-graphics {args_str}"
- subs = generate_subs(cli, out_bytes, image_metadata=metadata, command=command)
+ subs = generate_subs(cli, out_bytes, image_metadata=metadata, command_name="painter_convert_graphics")
# Render and write the header file
header_text = render_header(subs)
diff --git a/lib/python/qmk/cli/painter/make_font.py b/lib/python/qmk/cli/painter/make_font.py
index 19db844931..3e18fd74a5 100644
--- a/lib/python/qmk/cli/painter/make_font.py
+++ b/lib/python/qmk/cli/painter/make_font.py
@@ -61,10 +61,8 @@ def painter_convert_font_image(cli):
return
# Work out the text substitutions for rendering the output data
- args_str = " ".join((f"--{arg} {getattr(cli.args, arg.replace('-', '_'))}" for arg in ["input", "output", "no-ascii", "unicode-glyphs", "format", "no-rle"]))
- command = f"qmk painter-convert-font-image {args_str}"
metadata = {"glyphs": _generate_font_glyphs_list(not cli.args.no_ascii, cli.args.unicode_glyphs)}
- subs = generate_subs(cli, out_bytes, font_metadata=metadata, command=command)
+ subs = generate_subs(cli, out_bytes, font_metadata=metadata, command_name="painter_convert_font_image")
# Render and write the header file
header_text = render_header(subs)