2021-07-21 00:52:14 +06:00
|
|
|
"""Point people to the new command name.
|
2019-08-22 23:18:52 +06:00
|
|
|
"""
|
2021-07-21 00:52:14 +06:00
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
2019-08-22 23:18:52 +06:00
|
|
|
|
|
|
|
from milc import cli
|
2020-05-27 02:05:41 +06:00
|
|
|
|
2021-05-11 00:18:44 +06:00
|
|
|
|
|
|
|
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Flag only, don't automatically format.")
|
2020-02-23 10:57:19 +06:00
|
|
|
@cli.argument('-b', '--base-branch', default='origin/master', help='Branch to compare to diffs to.')
|
2021-05-11 00:18:44 +06:00
|
|
|
@cli.argument('-a', '--all-files', arg_only=True, action='store_true', help='Format all core files.')
|
2021-05-19 01:26:17 +06:00
|
|
|
@cli.argument('--core-only', arg_only=True, action='store_true', help='Format core files only.')
|
2021-07-21 00:52:14 +06:00
|
|
|
@cli.argument('files', nargs='*', arg_only=True, help='Filename(s) to format.')
|
|
|
|
@cli.subcommand('Pointer to the new command name: qmk format-c.', hidden=True)
|
2020-02-23 10:57:19 +06:00
|
|
|
def cformat(cli):
|
2021-07-21 00:52:14 +06:00
|
|
|
"""Pointer to the new command name: qmk format-c.
|
2020-02-23 10:57:19 +06:00
|
|
|
"""
|
2021-07-21 00:52:14 +06:00
|
|
|
cli.log.warning('"qmk cformat" has been renamed to "qmk format-c". Please use the new command in the future.')
|
|
|
|
argv = [sys.executable, *sys.argv]
|
|
|
|
argv[argv.index('cformat')] = 'format-c'
|
|
|
|
script_path = Path(argv[1])
|
|
|
|
script_path_exe = Path(f'{argv[1]}.exe')
|
2021-05-11 00:18:44 +06:00
|
|
|
|
2021-07-21 00:52:14 +06: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)
|
2020-02-23 10:57:19 +06:00
|
|
|
|
2021-07-21 00:52:14 +06:00
|
|
|
return cli.run(argv, capture_output=False).returncode
|