1 # Copyright (C) 2013 W. Trevor King <wking@tremily.us>
3 # This file is part of quizzer.
5 # quizzer is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 3 of the License, or (at your option) any later
10 # quizzer is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # quizzer. If not, see <http://www.gnu.org/licenses/>.
17 import argparse as _argparse
18 import locale as _locale
20 from . import __doc__ as _module_doc
21 from . import __version__
22 from . import answerdb as _answerdb
23 from . import quiz as _quiz
24 from .ui import cli as _cli
28 encoding = _locale.getpreferredencoding(do_setlocale=True)
30 parser = _argparse.ArgumentParser(description=_module_doc)
32 '--version', action='version',
33 version='%(prog)s {}'.format(__version__))
35 '-a', '--answers', metavar='ANSWERS', default='answers.json',
36 help='path to an answers database')
38 '--all', action='store_const', const=True, default=False,
39 help=('ask all questions '
40 '(not just never-correctly-answered leaf questions)'))
42 'quiz', metavar='QUIZ',
43 help='path to a quiz file')
45 args = parser.parse_args()
47 quiz = _quiz.Quiz(path=args.quiz, encoding=encoding)
49 answers = _answerdb.AnswerDatabase(path=args.answers, encoding=encoding)
56 stack = [question for question in quiz]
57 ui = _cli.CommandLineInterface(quiz=quiz, answers=answers, stack=stack)