(args)
return parser.parse_args(args)
Parse commandline arguments
Parse commandline arguments
Parse commandline arguments
def get_args(args):
    """Parse commandline arguments"""
    parent_parser = argparse.ArgumentParser(
        add_help=False, description='Lightweight time management CLI tool')
    parent_parser.add_argument(
        '-n', '--no-timer', action='store_true', help='Hide the countdown timer')
    parent_parser.add_argument(
        '-c', '--command', type=str, help='Use a custom command instead of the default beep')

    parser = argparse.ArgumentParser() 
    parser.add_argument('-v', '--version', action='version', version=VERSION)
    subparsers = parser.add_subparsers(dest='mode')                                             
    subparsers.required = True

    parser_in = subparsers.add_parser('in', parents=[parent_parser])
    parser_in.add_argument('time', nargs='+', type=relative_time,
            help='relative time \d+[smh]( +\d+[smh])* (e.g. 1h 30m)')                     

    parser_every = subparsers.add_parser('every', parents=[parent_parser])
    parser_every.add_argument('time', nargs='+', type=relative_time,
            help='relative time \d+[smh]( +\d+[smh])* (e.g. 2m 15s)')      

    parser_at = subparsers.add_parser('at', parents=[parent_parser])                          
    parser_at.add_argument('time', type=absolute_time, help='absolute time [hh:[mm[:ss]]]')       

    return parser.parse_args(args)
def get_args ( args ) : parent_parser = argparse . ArgumentParser ( add_help = False , description = 'Lightweight time management CLI tool' ) parent_parser . add_argument ( '-n' , '--no-timer' , action = 'store_true' , help = 'Hide the countdown timer' ) parent_parser . add_argument ( '-c' , '--command' , type = str , help = 'Use a custom command instead of the default beep' ) parser = argparse . ArgumentParser ( ) parser . add_argument ( '-v' , '--version' , action = 'version' , version = VERSION ) subparsers = parser . add_subparsers ( dest = 'mode' ) subparsers . required = True parser_in = subparsers . add_parser ( 'in' , parents = [ parent_parser ] ) parser_in . add_argument ( 'time' , nargs = '+' , type = relative_time , help = 'relative time \d+[smh]( +\d+[smh])* (e.g. 1h 30m)' ) parser_every = subparsers . add_parser ( 'every' , parents = [ parent_parser ] ) parser_every . add_argument ( 'time' , nargs = '+' , type = relative_time , help = 'relative time \d+[smh]( +\d+[smh])* (e.g. 2m 15s)' ) parser_at = subparsers . add_parser ( 'at' , parents = [ parent_parser ] ) parser_at . add_argument ( 'time' , type = absolute_time , help = 'absolute time [hh:[mm[:ss]]]' ) return parser . parse_args ( args )