diff --git a/qmk_cli/subcommands/__init__.py b/qmk_cli/subcommands/__init__.py index 3b50b61..0eaf4ee 100644 --- a/qmk_cli/subcommands/__init__.py +++ b/qmk_cli/subcommands/__init__.py @@ -3,4 +3,5 @@ We list each subcommand here explicitly because all the reliable ways of searching for modules are slow and delay startup. """ from . import clone # noqa +from . import env # noqa from . import setup # noqa diff --git a/qmk_cli/subcommands/env.py b/qmk_cli/subcommands/env.py new file mode 100644 index 0000000..d830b2f --- /dev/null +++ b/qmk_cli/subcommands/env.py @@ -0,0 +1,30 @@ +"""Prints environment information. +""" +import os +from pathlib import Path + +from milc import cli +from qmk_cli.helpers import is_qmk_firmware + + +@cli.argument('var', default=None, nargs='?', help='Optional variable to query') +@cli.subcommand('Prints environment information.') +def env(cli): + home = os.environ.get('QMK_HOME', "") + data = { + 'QMK_HOME': home, + 'QMK_FIRMWARE': home if is_qmk_firmware(Path(home)) else "" + } + + # Now munge the current cli config + for key, val in cli.config.general.items(): + converted_key = 'QMK_' + key.upper() + data[converted_key] = val + + if cli.args.var: + # dump out requested arg + print(data[cli.args.var]) + else: + # dump out everything + for key, val in data.items(): + print(f'{key}="{val}"')