aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/quarg/actions.py
diff options
context:
space:
mode:
authorWolfgang Müller2021-05-02 13:21:34 +0200
committerWolfgang Müller2021-05-02 13:35:44 +0200
commit8461abd6a2b97616e993ef0524db8f672cc6d9d4 (patch)
treea85a2f4e8a9f4c42394f27ed7633d6ff384464e2 /quarg/actions.py
parentc5207eabbb693d441776eadc1082e35fa8fd32b1 (diff)
downloadquarg-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.py7
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: