2021-07-20 20:52:14 +02:00
|
|
|
"""Point people to the new command name.
|
2019-08-22 18:40:12 +02:00
|
|
|
"""
|
2021-07-20 20:52:14 +02:00
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
2019-08-22 18:40:12 +02:00
|
|
|
|
2021-05-20 00:24:46 +02:00
|
|
|
from milc import cli
|
2019-08-22 18:40:12 +02:00
|
|
|
|
|
|
|
|
2021-07-20 20:52:14 +02: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 22:25:33 +02:00
|
|
|
def pyformat(cli):
|
2021-07-20 20:52:14 +02:00
|
|
|
"""Pointer to the new command name: qmk format-python.
|
2019-08-22 18:40:12 +02:00
|
|
|
"""
|
2021-07-20 20:52:14 +02: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 22:25:33 +02:00
|
|
|
|
2021-07-20 20:52:14 +02: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 20:18:44 +02:00
|
|
|
|
2021-07-20 20:52:14 +02:00
|
|
|
return cli.run(argv, capture_output=False).returncode
|