Skip to content

Commit

Permalink
readability enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
skullydazed committed Aug 31, 2019
1 parent 1784d1b commit 2d688ad
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/python/qmk/cli/cformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ def main(cli):
"""Format C code according to QMK's style.
"""
clang_format = ['clang-format', '-i']

# Find the list of files to format
if not cli.args.files:
for dir in ['drivers', 'quantum', 'tests', 'tmk_core']:
for dirpath, dirnames, filenames in os.walk(dir):
if 'tmk_core/protocol/usb_hid' in dirpath:
continue

for name in filenames:
if name.endswith('.c') or name.endswith('.h') or name.endswith('.cpp'):
cli.args.files.append(os.path.join(dirpath, name))

# Run clang-format on the files we've found
try:
subprocess.run(clang_format + cli.args.files, check=True)
cli.log.info('Successfully formatted the C code.')

except subprocess.CalledProcessError:
cli.log.error('Error formatting C code!')
return False

0 comments on commit 2d688ad

Please sign in to comment.