diff options
author | Wolfgang Müller | 2021-05-02 13:21:34 +0200 |
---|---|---|
committer | Wolfgang Müller | 2021-05-02 13:35:44 +0200 |
commit | 8461abd6a2b97616e993ef0524db8f672cc6d9d4 (patch) | |
tree | a85a2f4e8a9f4c42394f27ed7633d6ff384464e2 /quarg/actions.py | |
parent | c5207eabbb693d441776eadc1082e35fa8fd32b1 (diff) | |
download | quarg-8461abd6a2b97616e993ef0524db8f672cc6d9d4.tar.gz |
Add option to specify the order for printed messages
As mentioned in the previous commit, this change makes it possible to
select the first or last N matches in conjunction with the -l flag.
Diffstat (limited to 'quarg/actions.py')
-rw-r--r-- | quarg/actions.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/quarg/actions.py b/quarg/actions.py index 70cde03..6aadc3d 100644 --- a/quarg/actions.py +++ b/quarg/actions.py @@ -45,6 +45,13 @@ class ParseDate(argparse.Action): def __call__(self, parser, namespace, datespec, option_string=None): setattr(namespace, self.dest, parse_isodate(datespec)) +class ParseOrder(argparse.Action): + def __call__(self, parser, namespace, orderspec, option_string=None): + if orderspec not in ['asc', 'desc']: + errx(f'Invalid order \'{orderspec}\'. Possible values are: asc, desc') + + setattr(namespace, self.dest, orderspec) + class ParseAround(argparse.Action): def __call__(self, parser, namespace, aroundspec, option_string=None): if '/' in aroundspec: |