def main():
    'Orchestration function for the CLI.'
    args = _parse_args()
    path = pathlib.Path('lists', args.words)
    try:
        words = _load_words(path)
    except IOError:
        print('Exiting.')
        return
    if (args.quiz_length is not None):
        if (args.quiz_length == 0):
            print('Starting quiz in endless mode. Answer `quit` to end the quiz.')
            (correct, answered) = _quiz_endless(words)
        elif (args.quiz_length > 0):
            print(f'''Starting quiz with length {args.quiz_length}...
''')
            (correct, answered, _) = _quiz(words, args.quiz_length)
        else:
            raise ValueError(f'Invalid quiz length: {args.quiz_length}.')
        print(f'''
You successfully answered {correct} out of {answered} questions!''')
    elif args.add_words:
        print('Entering word addition mode...')
        _add_words(words)
    elif args.load_words:
        print(f'Importing word file {args.load_words}...')
        (added, reps) = _import_words(words, args.load_words)
        print(f'{added} words successfully imported. {reps} duplicates skipped.')
    elif args.reset_scores:
        print('Resetting scores')
        words = WordList()
        words.new()
        _import_words(words, path.with_suffix('.csv'))
    _save_and_exit(words, path)
Orchestration function for the CLI.
def main():
    
    args = _parse_args()
    path = pathlib.Path('lists', args.words)
    try:
        words = _load_words(path)
    except IOError:
        print('Exiting.')
        return
    if (args.quiz_length is not None):
        if (args.quiz_length == 0):
            print('Starting quiz in endless mode. Answer `quit` to end the quiz.')
            (correct, answered) = _quiz_endless(words)
        elif (args.quiz_length > 0):
            print(f'Starting quiz with length {args.quiz_length}...
')
            (correct, answered, _) = _quiz(words, args.quiz_length)
        else:
            raise ValueError(f'Invalid quiz length: {args.quiz_length}.')
        print(f'
You successfully answered {correct} out of {answered} questions!')
    elif args.add_words:
        print('Entering word addition mode...')
        _add_words(words)
    elif args.load_words:
        print(f'Importing word file {args.load_words}...')
        (added, reps) = _import_words(words, args.load_words)
        print(f'{added} words successfully imported. {reps} duplicates skipped.')
    elif args.reset_scores:
        print('Resetting scores')
        words = WordList()
        words.new()
        _import_words(words, path.with_suffix('.csv'))
    _save_and_exit(words, path)