From: W. Trevor King Date: Wed, 6 Feb 2013 17:41:23 +0000 (-0500) Subject: cli: Add the --questions option to list questions on the stack X-Git-Tag: v0.1~27 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=15f04b24ca0b7c9bd37273a584154e2e43f14606;p=quizzer.git 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. --- 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()