From 15f04b24ca0b7c9bd37273a584154e2e43f14606 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 6 Feb 2013 12:41:23 -0500 Subject: [PATCH] cli: Add the --questions option to list questions on the stack This lets you see what a quiz will ask without actually taking the quiz. In the future, it may be useful for jumping to a specific question. --- quizzer/cli.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/quizzer/cli.py b/quizzer/cli.py index e40332f..60cd645 100644 --- a/quizzer/cli.py +++ b/quizzer/cli.py @@ -44,6 +44,10 @@ def main(): 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( + '--questions', action='store_const', const=True, default=False, + help=('instead of running the quiz, ' + 'print a list of questions on the stack')) parser.add_argument( 'quiz', metavar='QUIZ', help='path to a quiz file') @@ -70,6 +74,12 @@ def main(): for tag in sorted(tags): print(tag) return + if args.questions: + for i,q in enumerate(stack): + print('Question {}:'.format(i)) + print(q.prompt) + print() + return ui = _cli.CommandLineInterface(quiz=quiz, answers=answers, stack=stack) ui.run() ui.answers.save() -- 2.26.2