diff options
author | Zach White <skullydazed@gmail.com> | 2021-07-20 11:52:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 11:52:14 -0700 |
commit | 4ab8734d6edd6894757507e70264eddca5429052 (patch) | |
tree | b43ad3f47426d3c194b05d02ae5ff34d6b0c1301 /lib/python/qmk/cli/fileformat.py | |
parent | c4db9f7fb2a359abb1db06e3d74a52dce8bdf68c (diff) | |
download | qmk_firmware-4ab8734d6edd6894757507e70264eddca5429052.tar.gz qmk_firmware-4ab8734d6edd6894757507e70264eddca5429052.zip |
Move all our CLI file formatters to the format dir (#13296)
* move all our file formatters to the format dir
* Apply suggestions from code review
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Diffstat (limited to 'lib/python/qmk/cli/fileformat.py')
-rwxr-xr-x[-rw-r--r--] | lib/python/qmk/cli/fileformat.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/python/qmk/cli/fileformat.py b/lib/python/qmk/cli/fileformat.py index 112d8d59d..cee4ba1ac 100644..100755 --- a/lib/python/qmk/cli/fileformat.py +++ b/lib/python/qmk/cli/fileformat.py | |||
@@ -1,13 +1,23 @@ | |||
1 | """Format files according to QMK's style. | 1 | """Point people to the new command name. |
2 | """ | 2 | """ |
3 | from milc import cli | 3 | import sys |
4 | from pathlib import Path | ||
4 | 5 | ||
5 | import subprocess | 6 | from milc import cli |
6 | 7 | ||
7 | 8 | ||
8 | @cli.subcommand("Format files according to QMK's style.", hidden=True) | 9 | @cli.subcommand('Pointer to the new command name: qmk format-text.', hidden=True) |
9 | def fileformat(cli): | 10 | def fileformat(cli): |
10 | """Run several general formatting commands. | 11 | """Pointer to the new command name: qmk format-text. |
11 | """ | 12 | """ |
12 | dos2unix = subprocess.run(['bash', '-c', 'git ls-files -z | xargs -0 dos2unix'], stdout=subprocess.DEVNULL) | 13 | cli.log.warning('"qmk fileformat" has been renamed to "qmk format-text". Please use the new command in the future.') |
13 | return dos2unix.returncode | 14 | argv = [sys.executable, *sys.argv] |
15 | argv[argv.index('fileformat')] = 'format-text' | ||
16 | script_path = Path(argv[1]) | ||
17 | script_path_exe = Path(f'{argv[1]}.exe') | ||
18 | |||
19 | if not script_path.exists() and script_path_exe.exists(): | ||
20 | # For reasons I don't understand ".exe" is stripped from the script name on windows. | ||
21 | argv[1] = str(script_path_exe) | ||
22 | |||
23 | return cli.run(argv, capture_output=False).returncode | ||