diff options
| -rwxr-xr-x | mat2 | 31 | ||||
| -rw-r--r-- | tests/test_climat2.py | 10 |
2 files changed, 25 insertions, 16 deletions
| @@ -46,13 +46,7 @@ def __check_file(filename: str, mode: int = os.R_OK) -> bool: | |||
| 46 | 46 | ||
| 47 | def create_arg_parser() -> argparse.ArgumentParser: | 47 | def create_arg_parser() -> argparse.ArgumentParser: |
| 48 | parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit 2') | 48 | parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit 2') |
| 49 | parser.add_argument('files', nargs='*', help='the files to process') | 49 | |
| 50 | parser.add_argument('-v', '--version', action='version', | ||
| 51 | version='MAT2 %s' % __version__) | ||
| 52 | parser.add_argument('-l', '--list', action='store_true', | ||
| 53 | help='list all supported fileformats') | ||
| 54 | parser.add_argument('--check-dependencies', action='store_true', | ||
| 55 | help='check if MAT2 has all the dependencies it needs') | ||
| 56 | parser.add_argument('-V', '--verbose', action='store_true', | 50 | parser.add_argument('-V', '--verbose', action='store_true', |
| 57 | help='show more verbose status information') | 51 | help='show more verbose status information') |
| 58 | parser.add_argument('--unknown-members', metavar='policy', default='abort', | 52 | parser.add_argument('--unknown-members', metavar='policy', default='abort', |
| @@ -60,12 +54,25 @@ def create_arg_parser() -> argparse.ArgumentParser: | |||
| 60 | 'files (policy should be one of: %s) [Default: abort]' % | 54 | 'files (policy should be one of: %s) [Default: abort]' % |
| 61 | ', '.join(p.value for p in UnknownMemberPolicy)) | 55 | ', '.join(p.value for p in UnknownMemberPolicy)) |
| 62 | 56 | ||
| 57 | excl_group = parser.add_mutually_exclusive_group() | ||
| 58 | excl_group.add_argument('files', nargs='*', help='the files to process', | ||
| 59 | default=[]) | ||
| 60 | excl_group.add_argument('-v', '--version', action='version', | ||
| 61 | version='MAT2 %s' % __version__) | ||
| 62 | excl_group.add_argument('-l', '--list', action='store_true', default=False, | ||
| 63 | help='list all supported fileformats') | ||
| 64 | excl_group.add_argument('--check-dependencies', action='store_true', | ||
| 65 | default=False, | ||
| 66 | help='check if MAT2 has all the dependencies it ' | ||
| 67 | 'needs') | ||
| 68 | |||
| 69 | excl_group = parser.add_mutually_exclusive_group() | ||
| 70 | excl_group.add_argument('-L', '--lightweight', action='store_true', | ||
| 71 | help='remove SOME metadata') | ||
| 72 | excl_group.add_argument('-s', '--show', action='store_true', | ||
| 73 | help='list harmful metadata detectable by MAT2 ' | ||
| 74 | 'without removing them') | ||
| 63 | 75 | ||
| 64 | info = parser.add_mutually_exclusive_group() | ||
| 65 | info.add_argument('-s', '--show', action='store_true', | ||
| 66 | help='list harmful metadata detectable by MAT2 without removing them') | ||
| 67 | info.add_argument('-L', '--lightweight', action='store_true', | ||
| 68 | help='remove SOME metadata') | ||
| 69 | return parser | 76 | return parser |
| 70 | 77 | ||
| 71 | 78 | ||
diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 4a46644..bbb9c06 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py | |||
| @@ -20,16 +20,18 @@ class TestHelp(unittest.TestCase): | |||
| 20 | def test_help(self): | 20 | def test_help(self): |
| 21 | proc = subprocess.Popen(mat2_binary + ['--help'], stdout=subprocess.PIPE) | 21 | proc = subprocess.Popen(mat2_binary + ['--help'], stdout=subprocess.PIPE) |
| 22 | stdout, _ = proc.communicate() | 22 | stdout, _ = proc.communicate() |
| 23 | self.assertIn(b'usage: mat2 [-h] [-v] [-l] [--check-dependencies] [-V]', | 23 | self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [-v] [-l]', |
| 24 | stdout) | 24 | stdout) |
| 25 | self.assertIn(b'[--unknown-members policy] [-s | -L]', stdout) | 25 | self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) |
| 26 | self.assertIn(b'[files [files ...]]', stdout) | ||
| 26 | 27 | ||
| 27 | def test_no_arg(self): | 28 | def test_no_arg(self): |
| 28 | proc = subprocess.Popen(mat2_binary, stdout=subprocess.PIPE) | 29 | proc = subprocess.Popen(mat2_binary, stdout=subprocess.PIPE) |
| 29 | stdout, _ = proc.communicate() | 30 | stdout, _ = proc.communicate() |
| 30 | self.assertIn(b'usage: mat2 [-h] [-v] [-l] [--check-dependencies] [-V]', | 31 | self.assertIn(b'mat2 [-h] [-V] [--unknown-members policy] [-v] [-l]', |
| 31 | stdout) | 32 | stdout) |
| 32 | self.assertIn(b'[--unknown-members policy] [-s | -L]', stdout) | 33 | self.assertIn(b'[--check-dependencies] [-L | -s]', stdout) |
| 34 | self.assertIn(b'[files [files ...]]', stdout) | ||
| 33 | 35 | ||
| 34 | 36 | ||
| 35 | class TestVersion(unittest.TestCase): | 37 | class TestVersion(unittest.TestCase): |
