diff options
Diffstat (limited to 'mdbp/common.py')
-rw-r--r-- | mdbp/common.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mdbp/common.py b/mdbp/common.py index 8b7f8c1..7a528bc 100644 --- a/mdbp/common.py +++ b/mdbp/common.py @@ -191,3 +191,13 @@ def clean_dir(directory: pathlib.Path, patterns: typing.List[str]) -> None: if not any(fnmatch.fnmatchcase(entry.name, pattern) for pattern in patterns): entry.unlink() + +class AddSpaceSeparatedValues(argparse.Action): + """The action extends the destination array with the space-sparated parts + of the passed value.""" + def __call__(self, parser: argparse.ArgumentParser, + namespace: argparse.Namespace, + values: typing.Union[str, typing.Sequence[typing.Any], None], + option_string: typing.Optional[str] = None) -> None: + assert isinstance(values, str) + getattr(namespace, self.dest).extend(values.split()) |