ya3

ya3 -- yet another appointment application
Log | Files | Refs

commit e9c7e06890f837b6a8b22c6352ea6de3a91f8088
parent 23d252d8e859e951a1e004c45988c3c06f16afe9
Author: Matthias Balk <mbalk@mbalk.de>
Date:   Fri,  4 Sep 2020 15:09:50 +0200

switched to 'argparse', because 'optparse' is deprecated

Diffstat:
Msrc/ya3 | 28+++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/src/ya3 b/src/ya3 @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2018, 2019 Matthias Balk +# Copyright 2018, 2019, 2020 Matthias Balk # # This file is part of ya3 (yet another appointment application). # @@ -21,25 +21,19 @@ import glob import os.path -from optparse import OptionParser +from argparse import ArgumentParser import commands import config -usage = """%prog <command> - commands: create|add, print""" -parser = OptionParser(usage=usage) -(options, args) = parser.parse_args() +parser = ArgumentParser() +parser.add_argument('command', + choices=['create', 'add', 'print'], + help='create|add, print') +args = parser.parse_args() -if len(args) != 1: - parser.print_help() -else: - command = args[0] - - if command == 'create' or command == 'add': - commands.create_event() - elif command == 'print': - commands.print_events(glob.glob(os.path.join(config.CAL_DIR, '*.ics'))) - else: - parser.print_help() +if args.command == 'create' or args.command == 'add': + commands.create_event() +elif args.command == 'print': + commands.print_events(glob.glob(os.path.join(config.CAL_DIR, '*.ics')))