Anton Shestakov <av6@dwimlabs.net>, Mon, 18 Jul 2016 19:17:54 +0800
rollbot: move logging options above main config, split the lines
Helps keeping options and their defaults closer to each other.
--- a/rollbot.py Mon Jul 18 19:17:30 2016 +0800
+++ b/rollbot.py Mon Jul 18 19:17:54 2016 +0800
'-c', '--config', type=FileType('r'),
help='configuration file (YAML)')
+ group = parser.add_mutually_exclusive_group()
+ extra = dict(action='store_const', dest='loglevel', default=logging.INFO)
+ '-q', '--quiet', const=logging.ERROR,
+ help='set logging to ERROR', **extra)
+ '-d', '--debug', const=logging.DEBUG,
+ help='set logging to DEBUG', **extra)
group = parser.add_argument_group(
'options that can also be specified in the configuration file')
group.add_argument('-n', '--nick', help='MUC nickname (default: rollbot)')
group.add_argument('--prefix', help='command prefix (default: !)')
- group = parser.add_mutually_exclusive_group()
- extra = dict(action='store_const', dest='loglevel', default=logging.INFO)
- group.add_argument('-q', '--quiet', help='set logging to ERROR', const=logging.ERROR, **extra)
- group.add_argument('-d', '--debug', help='set logging to DEBUG', const=logging.DEBUG, **extra)
args = parser.parse_args()
config = yaml.safe_load(args.config) if hasattr(args, 'config') else {}