Created
September 13, 2017 05:54
-
-
Save morefreeze/f7834140f5f4addc86a40fe7f643cd23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
arg_parser = argparse.ArgumentParser() | |
def time_argument(func): | |
def _(*args, **kwargs): | |
arg_parser.add_argument('-b', '--begin_time', nargs='?', default=None, help='begin time, use yesterday if omit') | |
arg_parser.add_argument('-e', '--end_time', nargs='?', default=None, help='end time, use next day of begin_time if omit') | |
return func(*args, **kwargs) | |
return _ | |
def logger_argument(func): | |
def _(*args, **kwargs): | |
arg_parser.add_argument('-d', '--debug', action='store_true') | |
arg_parser.add_argument('-f', '--file', type=str, help='logging file') | |
return func(*args, **kwargs) | |
return _ | |
@logger_argument | |
@time_argument | |
def main(): | |
args = arg_parser.parse_args() | |
print args | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment