This commit is contained in:
Ryan Miguel 2023-01-14 11:49:11 -05:00 committed by GitHub
commit 96367aaa4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View file

@ -49,21 +49,26 @@ def sort_file_contents(
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(exit_on_error=False)
parser.add_argument('filenames', nargs='+', help='Files to sort')
parser.add_argument(
group = parser.add_mutually_exclusive_group()
group.add_argument(
'--ignore-case',
action='store_const',
const=bytes.lower,
default=None,
help='fold lower case to upper case characters',
)
parser.add_argument(
group.add_argument(
'--unique',
action='store_true',
help='ensure each line is unique',
)
args = parser.parse_args(argv)
try:
args = parser.parse_args(argv)
except argparse.ArgumentError as e:
print(f'{e}')
return FAIL
retv = PASS

View file

@ -68,12 +68,6 @@ from pre_commit_hooks.file_contents_sorter import PASS
(
b'fee\nFie\nFoe\nfum\n',
['--unique', '--ignore-case'],
PASS,
b'fee\nFie\nFoe\nfum\n',
),
(
b'fee\nfee\nFie\nFoe\nfum\n',
['--unique', '--ignore-case'],
FAIL,
b'fee\nFie\nFoe\nfum\n',
),