cformat.py 1.3 KB

12345678910111213141516171819202122232425262728
  1. """Point people to the new command name.
  2. """
  3. import sys
  4. from pathlib import Path
  5. from milc import cli
  6. @cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Flag only, don't automatically format.")
  7. @cli.argument('-b', '--base-branch', default='origin/master', help='Branch to compare to diffs to.')
  8. @cli.argument('-a', '--all-files', arg_only=True, action='store_true', help='Format all core files.')
  9. @cli.argument('--core-only', arg_only=True, action='store_true', help='Format core files only.')
  10. @cli.argument('files', nargs='*', arg_only=True, help='Filename(s) to format.')
  11. @cli.subcommand('Pointer to the new command name: qmk format-c.', hidden=True)
  12. def cformat(cli):
  13. """Pointer to the new command name: qmk format-c.
  14. """
  15. cli.log.warning('"qmk cformat" has been renamed to "qmk format-c". Please use the new command in the future.')
  16. argv = [sys.executable, *sys.argv]
  17. argv[argv.index('cformat')] = 'format-c'
  18. script_path = Path(argv[1])
  19. script_path_exe = Path(f'{argv[1]}.exe')
  20. if not script_path.exists() and script_path_exe.exists():
  21. # For reasons I don't understand ".exe" is stripped from the script name on windows.
  22. argv[1] = str(script_path_exe)
  23. return cli.run(argv, capture_output=False).returncode