From a27c0e75e7e96f1a29c63e1dcee744ed0b333b4d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 6 Feb 2013 09:59:11 -0500 Subject: [PATCH 1/1] cli: Add the --tags option to list tags on the stack --- quizzer/cli.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/quizzer/cli.py b/quizzer/cli.py index 4df0b15..e40332f 100644 --- a/quizzer/cli.py +++ b/quizzer/cli.py @@ -41,6 +41,9 @@ def main(): parser.add_argument( '-t', '--tag', action='append', help='limit original questions to those matching at least one tag') + parser.add_argument( + '--tags', action='store_const', const=True, default=False, + help='instead of running the quiz, print a list of tags on the stack') parser.add_argument( 'quiz', metavar='QUIZ', help='path to a quiz file') @@ -60,6 +63,13 @@ def main(): stack = [question for question in quiz] if args.tag: stack = [q for q in stack if q.tags.intersection(args.tag)] + if args.tags: + tags = set() + for q in stack: + tags.update(q.tags) + for tag in sorted(tags): + print(tag) + return ui = _cli.CommandLineInterface(quiz=quiz, answers=answers, stack=stack) ui.run() ui.answers.save() -- 2.26.2