From 5915a25064e01c38c49787322ca1309d0da0386a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 30 Jan 2023 14:34:55 +0100 Subject: ... --- tools/sops-inventory/sops_inventory/__main__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tools/sops-inventory') diff --git a/tools/sops-inventory/sops_inventory/__main__.py b/tools/sops-inventory/sops_inventory/__main__.py index f84567d3..aaddda8c 100644 --- a/tools/sops-inventory/sops_inventory/__main__.py +++ b/tools/sops-inventory/sops_inventory/__main__.py @@ -4,6 +4,7 @@ from pathlib import Path from collections import deque, defaultdict import argparse +import re import subprocess @@ -45,7 +46,7 @@ class BooleanAction(argparse.Action): super(BooleanAction, self).__init__(option_strings, dest, nargs=0, **kwargs) def __call__(self, parser, namespace, values, option_string=None): - setattr(namespace, self.dest, False if option_string.startswith('--no') else True) + setattr(namespace, self.dest, False if option_string.startswith('--no') or re.match('^-[A-Z]$', option_string) else True) def sops_files(path): @@ -86,8 +87,8 @@ def sops_files(path): raise RuntimeError(f'git ls-files returned with {proc.returncode}') def main(): - parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument('--list-files', '--no-list-files', action=BooleanAction, default=False, help='Only list sops files') + parser = argparse.ArgumentParser(prog='sops-inventory', formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument('--list-files', '--no-list-files', '-l', '-L', action=BooleanAction, default=False, help='Only list sops files') parser.add_argument('path', metavar='PATH', nargs='?', type=Path, default=Path('.'), help='Base directory to take inventory of') args = parser.parse_args() -- cgit v1.2.3