diff options
author | Zach White <[email protected]> | 2021-07-20 11:52:14 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-07-20 11:52:14 -0700 |
commit | 4ab8734d6edd6894757507e70264eddca5429052 (patch) | |
tree | b43ad3f47426d3c194b05d02ae5ff34d6b0c1301 /lib/python/qmk/cli/format/text.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 <[email protected]>
Co-authored-by: Erovia <[email protected]>
Diffstat (limited to 'lib/python/qmk/cli/format/text.py')
-rw-r--r-- | lib/python/qmk/cli/format/text.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/python/qmk/cli/format/text.py b/lib/python/qmk/cli/format/text.py new file mode 100644 index 0000000000..e7e07b7297 --- /dev/null +++ b/lib/python/qmk/cli/format/text.py @@ -0,0 +1,27 @@ +"""Ensure text files have the proper line endings. +""" +from subprocess import CalledProcessError + +from milc import cli + + [email protected]("Ensure text files have the proper line endings.", hidden=True) +def format_text(cli): + """Ensure text files have the proper line endings. + """ + try: + file_list_cmd = cli.run(['git', 'ls-files', '-z'], check=True) + except CalledProcessError as e: + cli.log.error('Could not get file list: %s', e) + exit(1) + except Exception as e: + cli.log.error('Unhandled exception: %s: %s', e.__class__.__name__, e) + cli.log.exception(e) + exit(1) + + dos2unix = cli.run(['xargs', '-0', 'dos2unix'], stdin=None, input=file_list_cmd.stdout) + + if dos2unix.returncode != 0: + print(dos2unix.stderr) + + return dos2unix.returncode |