summaryrefslogtreecommitdiff
path: root/tools/sops-inventory
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2023-01-30 14:34:55 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2023-01-30 14:34:55 +0100
commit5915a25064e01c38c49787322ca1309d0da0386a (patch)
tree9fd302fa171c5fb6dbfeddfffdc1e30629bca1db /tools/sops-inventory
parent1a69390d630e4f886e46ab2d9817d2b352f05aa9 (diff)
downloadnixos-5915a25064e01c38c49787322ca1309d0da0386a.tar
nixos-5915a25064e01c38c49787322ca1309d0da0386a.tar.gz
nixos-5915a25064e01c38c49787322ca1309d0da0386a.tar.bz2
nixos-5915a25064e01c38c49787322ca1309d0da0386a.tar.xz
nixos-5915a25064e01c38c49787322ca1309d0da0386a.zip
...
Diffstat (limited to 'tools/sops-inventory')
-rw-r--r--tools/sops-inventory/sops_inventory/__main__.py7
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
4from collections import deque, defaultdict 4from collections import deque, defaultdict
5 5
6import argparse 6import argparse
7import re
7 8
8import subprocess 9import 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
51def sops_files(path): 52def 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
88def main(): 89def 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