pyformat.py 957 B

123456789101112131415161718192021222324
  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="Don't actually format.")
  7. @cli.subcommand('Pointer to the new command name: qmk format-python.', hidden=False if cli.config.user.developer else True)
  8. def pyformat(cli):
  9. """Pointer to the new command name: qmk format-python.
  10. """
  11. cli.log.warning('"qmk pyformat" has been renamed to "qmk format-python". Please use the new command in the future.')
  12. argv = [sys.executable, *sys.argv]
  13. argv[argv.index('pyformat')] = 'format-python'
  14. script_path = Path(argv[1])
  15. script_path_exe = Path(f'{argv[1]}.exe')
  16. if not script_path.exists() and script_path_exe.exists():
  17. # For reasons I don't understand ".exe" is stripped from the script name on windows.
  18. argv[1] = str(script_path_exe)
  19. return cli.run(argv, capture_output=False).returncode