544 usage = "%prog [options] <command> [ ... ]", |
541 usage = "%prog [options] <command> [ ... ]", |
545 add_help_option = False, |
542 add_help_option = False, |
546 option_class = MyOption, |
543 option_class = MyOption, |
547 ) |
544 ) |
548 |
545 |
549 # define command-line arguments |
546 # general options # # # # |
550 general = optparse.OptionGroup(parser, "General Options") |
547 general = optparse.OptionGroup(parser, "General Options") |
551 general.add_option('-h', "--help", dest="help", help="Show this help message and exit", action="store_true" ) |
548 general.add_option('-h', "--help", dest="help", help="Show this help message and exit", |
552 general.add_option( "--formatter", dest="formatter_name", help="LogFormatter to use", metavar="FMT", type="choice", default="irssi", |
549 action="store_true" ) |
553 choices=[fmt_name for fmt_name in config.LOG_FORMATTERS.iterkeys()]) |
550 |
554 |
551 general.add_option( "--formatter", dest="formatter_name", help="LogFormatter to use", |
555 general.add_option( "--index", dest="index_path", help="Index database path", metavar="PATH", default="logs/index" ) |
552 metavar="FMT", type="choice", default="irssi", |
556 general.add_option( "--timezone", dest="timezone", help="Timezone for output", metavar="TZ", type="timezone", default=pytz.utc ) |
553 choices=[fmt_name for fmt_name in config.LOG_FORMATTERS.iterkeys()] ) |
557 general.add_option( "--force", dest="force", help="Force dangerous operation", action="store_true" ) |
554 |
558 general.add_option( "--quiet", dest="quiet", help="Supress status messages", action="store_true" ) |
555 general.add_option( "--index", dest="index_path", help="Index database path", |
|
556 metavar="PATH", default="logs/index" ) |
|
557 |
|
558 general.add_option( "--timezone", dest="timezone", help="Timezone for output", |
|
559 metavar="TZ", type="timezone", default=pytz.utc ) |
|
560 |
|
561 general.add_option( "--force", dest="force", help="Force dangerous operation", |
|
562 action="store_true" ) |
|
563 |
|
564 general.add_option( "--quiet", dest="quiet", help="Supress status messages", |
|
565 action="store_true" ) |
559 parser.add_option_group(general) |
566 parser.add_option_group(general) |
560 |
567 |
|
568 |
|
569 # cmd_load options # # # # |
561 load = optparse.OptionGroup(parser, "Load Options") |
570 load = optparse.OptionGroup(parser, "Load Options") |
562 load.add_option( "--skip-missing", dest="skip_missing", help="Skip missing logfiles", action="store_true" ) |
571 load.add_option( "--skip-missing", dest="skip_missing", help="Skip missing logfiles", |
563 load.add_option( "--create", dest="create", help="Create index database", action="store_true" ) |
572 action="store_true" ) |
|
573 |
|
574 load.add_option( "--create", dest="create", help="Create index database", |
|
575 action="store_true" ) |
564 parser.add_option_group(load) |
576 parser.add_option_group(load) |
565 |
577 |
|
578 |
|
579 # cmd_autoload options # # # # |
566 autoload = optparse.OptionGroup(parser, "Autoload Options") |
580 autoload = optparse.OptionGroup(parser, "Autoload Options") |
567 autoload.add_option( "--autoload-state", dest="autoload_state_path", help="Path to autoload state dir", metavar="PATH", default="logs/autoload-state" ) |
581 autoload.add_option( "--autoload-state", dest="autoload_state_path", help="Path to autoload state dir", |
568 autoload.add_option( "--after", dest="after", help="Only autoload logfiles after the given date", metavar="DATE", type="date", action="parse_date", default=None ) |
582 metavar="PATH", default="logs/autoload-state" ) |
569 autoload.add_option( "--until", dest="until", help="Only autoload logfiles up to the given date", metavar="DATE", type="date", action="parse_date", default=None ) |
583 |
570 autoload.add_option( "--reload", dest="reload", help="Force reload lines", action="store_true" ) |
584 autoload.add_option( "--from", dest="after", help="Only autoload logfiles from the given date on", |
571 autoload.add_option( "--reset", dest="reset", help="Reset old autload state", action="store_true" ) |
585 metavar="DATE", type="date", action="parse_date", default=None ) |
572 autoload.add_option( "--ignore-resume", dest="ignore_resume", help="Do not try and resume interrupted autoload", action="store_true" ) |
586 |
|
587 autoload.add_option( "--until", dest="until", help="Only autoload logfiles up to (and including) the given date", |
|
588 metavar="DATE", type="date", action="parse_date", default=None ) |
|
589 |
|
590 autoload.add_option( "--reload", dest="reload", help="Force reload lines", |
|
591 action="store_true" ) |
|
592 |
|
593 autoload.add_option( "--reset", dest="reset", help="Reset old autload state", |
|
594 action="store_true" ) |
|
595 |
|
596 autoload.add_option( "--ignore-resume", dest="ignore_resume", help="Do not try and resume interrupted autoload", |
|
597 action="store_true" ) |
573 parser.add_option_group(autoload) |
598 parser.add_option_group(autoload) |
574 |
599 |
575 # parse |
600 # parse |
576 options, args = parser.parse_args(argv[1:]) |
601 options, args = parser.parse_args(argv[1:]) |
577 |
602 |