#### #### The output #### usage: poca.py [-h] [-q] [-e [ERRORS_LOG_FILE]] [-E [ERRORS_LOG_MAIL]] [-r] [-R] [-t] poca r102 - a command line podcast client written in Python http://code.google.com/p/poca optional arguments: -h, --help show this help message and exit -q, --quiet Quiet mode (useful for cronjobs) error logging: -e [ERRORS_LOG_FILE], --errors-log-file [ERRORS_LOG_FILE] Specifies a file to use for error logging; if none are assigned the default errors.log in the .poca directory is used. -E [ERRORS_LOG_MAIL], --errors-log-mail [ERRORS_LOG_MAIL] Specifies a recipient email address to use for error logging (requires further account setup in poca.xml) test: -r, --reconfigure A more thorough update mode following changes to max_mb values -R, --restart Deletes all created directories with contents plus log file and starts over -t, --history-trim Does not update but reduces excessive log size #### #### The code #### import argparse def args_config(paths_dic, about): '''Returns arguments from a command line argument parser based on argparse''' _parser = argparse.ArgumentParser(description=about) _parser.add_argument('-q', '--quiet', action='store_true', \ default=False, help='Quiet mode (useful for cronjobs)') errors_group = _parser.add_argument_group(title='error logging') errors_group.add_argument('-e', '--errors-log-file', action='store', \ nargs='?', const=paths_dic['errors_log'], default=None, \ help='Specifies a file to use for error logging; \ if none are assigned the default errors.log in the \ .poca directory is used.') errors_group.add_argument('-E', '--errors-log-mail', action='store', \ nargs='?', default=None, help='Specifies a recipient email address \ to use for error logging (requires further account setup in poca.xml)') dummy_group = _parser.add_argument_group(title='test') runmode_group = dummy_group.add_mutually_exclusive_group() runmode_group.add_argument('-r', '--reconfigure', action='store_true', \ default=False, \ help='A more thorough update mode following changes to max_mb values') runmode_group.add_argument('-R', '--restart', action='store_true', \ default=False, help='Deletes all created directories with contents \ plus log file and starts over') runmode_group.add_argument('-t', '--history-trim', action='store_true', \ default=False, help='Does not update but reduces excessive log size') args_ns = _parser.parse_args() return args_ns