Skip to content

Commit

Permalink
Support restyling only the specified files
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Peskine <[email protected]>
  • Loading branch information
gilles-peskine-arm committed Dec 22, 2022
1 parent 8ee18d3 commit 38f514d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions scripts/code_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,26 @@ def main() -> int:
+ uncrustify_version + "' (Note: The only supported version" \
"is " + UNCRUSTIFY_SUPPORTED_VERSION + ")", file=STDOUT_UTF8)

src_files = get_src_files()

parser = argparse.ArgumentParser()
parser.add_argument('-f', '--fix', action='store_true', \
help='modify source files to fix the code style')
parser.add_argument('-f', '--fix', action='store_true',
help='modify source files to fix the code style')
# --files is almost useless: it only matters if there are no files
# ('code_style.py' without arguments checks all files known to Git,
# 'code_style.py --files' does nothing). 'code_style.py --files ...' is
# intended as a stable ("porcelain") way to restyle a possibly empty
# set of files.
parser.add_argument('--files', action='store_true',
help='only check the specified files (default with non-option arguments)')
parser.add_argument('operands', nargs='*', metavar='FILE',
help='files to check (if none: check files that are known to git)')

args = parser.parse_args()

if args.files or args.operands:
src_files = args.operands
else:
src_files = get_src_files()

if args.fix:
# Fix mode
return fix_style(src_files)
Expand Down

0 comments on commit 38f514d

Please sign in to comment.