diff options
Diffstat (limited to 'tools/sops-inventory')
-rw-r--r-- | tools/sops-inventory/sops_inventory/__main__.py | 7 |
1 files changed, 4 insertions, 3 deletions
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 | |||
4 | from collections import deque, defaultdict | 4 | from collections import deque, defaultdict |
5 | 5 | ||
6 | import argparse | 6 | import argparse |
7 | import re | ||
7 | 8 | ||
8 | import subprocess | 9 | import subprocess |
9 | 10 | ||
@@ -45,7 +46,7 @@ class BooleanAction(argparse.Action): | |||
45 | super(BooleanAction, self).__init__(option_strings, dest, nargs=0, **kwargs) | 46 | super(BooleanAction, self).__init__(option_strings, dest, nargs=0, **kwargs) |
46 | 47 | ||
47 | def __call__(self, parser, namespace, values, option_string=None): | 48 | def __call__(self, parser, namespace, values, option_string=None): |
48 | setattr(namespace, self.dest, False if option_string.startswith('--no') else True) | 49 | setattr(namespace, self.dest, False if option_string.startswith('--no') or re.match('^-[A-Z]$', option_string) else True) |
49 | 50 | ||
50 | 51 | ||
51 | def sops_files(path): | 52 | def sops_files(path): |
@@ -86,8 +87,8 @@ def sops_files(path): | |||
86 | raise RuntimeError(f'git ls-files returned with {proc.returncode}') | 87 | raise RuntimeError(f'git ls-files returned with {proc.returncode}') |
87 | 88 | ||
88 | def main(): | 89 | def main(): |
89 | parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) | 90 | parser = argparse.ArgumentParser(prog='sops-inventory', formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
90 | parser.add_argument('--list-files', '--no-list-files', action=BooleanAction, default=False, help='Only list sops files') | 91 | parser.add_argument('--list-files', '--no-list-files', '-l', '-L', action=BooleanAction, default=False, help='Only list sops files') |
91 | parser.add_argument('path', metavar='PATH', nargs='?', type=Path, default=Path('.'), help='Base directory to take inventory of') | 92 | parser.add_argument('path', metavar='PATH', nargs='?', type=Path, default=Path('.'), help='Base directory to take inventory of') |
92 | args = parser.parse_args() | 93 | args = parser.parse_args() |
93 | 94 | ||