2021-07-20 18:52:14 +00:00
|
|
|
"""Point people to the new command name.
|
2019-08-22 16:40:12 +00:00
|
|
|
"""
|
2021-07-20 18:52:14 +00:00
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
2019-08-22 16:40:12 +00:00
|
|
|
|
2021-05-19 22:24:46 +00:00
|
|
|
from milc import cli
|
2019-08-22 16:40:12 +00:00
|
|
|
|
|
|
|
|
2021-07-20 18:52:14 +00:00
|
|
|
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually format.")
|
|
|
|
@cli.subcommand('Pointer to the new command name: qmk format-python.', hidden=False if cli.config.user.developer else True)
|
2019-09-22 20:25:33 +00:00
|
|
|
def pyformat(cli):
|
2021-07-20 18:52:14 +00:00
|
|
|
"""Pointer to the new command name: qmk format-python.
|
2019-08-22 16:40:12 +00:00
|
|
|
"""
|
2021-07-20 18:52:14 +00:00
|
|
|
cli.log.warning('"qmk pyformat" has been renamed to "qmk format-python". Please use the new command in the future.')
|
|
|
|
argv = [sys.executable, *sys.argv]
|
|
|
|
argv[argv.index('pyformat')] = 'format-python'
|
|
|
|
script_path = Path(argv[1])
|
|
|
|
script_path_exe = Path(f'{argv[1]}.exe')
|
2019-09-22 20:25:33 +00:00
|
|
|
|
2021-07-20 18:52:14 +00:00
|
|
|
if not script_path.exists() and script_path_exe.exists():
|
|
|
|
# For reasons I don't understand ".exe" is stripped from the script name on windows.
|
|
|
|
argv[1] = str(script_path_exe)
|
2021-05-10 18:18:44 +00:00
|
|
|
|
2021-07-20 18:52:14 +00:00
|
|
|
return cli.run(argv, capture_output=False).returncode
|