2021-07-20 18:52:14 +00:00
|
|
|
"""Point people to the new command name.
|
2019-08-22 17:18:52 +00:00
|
|
|
"""
|
2021-07-20 18:52:14 +00:00
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
2019-08-22 17:18:52 +00:00
|
|
|
|
|
|
|
from milc import cli
|
2020-05-26 20:05:41 +00:00
|
|
|
|
2021-05-10 18:18:44 +00:00
|
|
|
|
|
|
|
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Flag only, don't automatically format.")
|
2020-02-23 04:57:19 +00:00
|
|
|
@cli.argument('-b', '--base-branch', default='origin/master', help='Branch to compare to diffs to.')
|
2021-05-10 18:18:44 +00:00
|
|
|
@cli.argument('-a', '--all-files', arg_only=True, action='store_true', help='Format all core files.')
|
2021-05-18 19:26:17 +00:00
|
|
|
@cli.argument('--core-only', arg_only=True, action='store_true', help='Format core files only.')
|
2021-07-20 18:52:14 +00: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 04:57:19 +00:00
|
|
|
def cformat(cli):
|
2021-07-20 18:52:14 +00:00
|
|
|
"""Pointer to the new command name: qmk format-c.
|
2020-02-23 04:57:19 +00:00
|
|
|
"""
|
2021-07-20 18:52:14 +00: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-10 18:18:44 +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)
|
2020-02-23 04:57:19 +00:00
|
|
|
|
2021-07-20 18:52:14 +00:00
|
|
|
return cli.run(argv, capture_output=False).returncode
|