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>
This commit is contained in:
parent
c4db9f7fb2
commit
4ab8734d6e
7 changed files with 240 additions and 148 deletions
27
lib/python/qmk/cli/format/text.py
Normal file
27
lib/python/qmk/cli/format/text.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
"""Ensure text files have the proper line endings.
|
||||
"""
|
||||
from subprocess import CalledProcessError
|
||||
|
||||
from milc import cli
|
||||
|
||||
|
||||
@cli.subcommand("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
|
Loading…
Add table
Add a link
Reference in a new issue