use dash instead of underscore

This commit is contained in:
Yohann Rebattu 2016-10-12 10:44:13 +02:00
parent d6ee788ff5
commit fb3e733596

View File

@ -37,29 +37,29 @@ from . import (
ThreadedHTTPSServer, config, log) ThreadedHTTPSServer, config, log)
opt_dict = { opt_dict = {
'--server_daemon': { '--server-daemon': {
'help': 'launch as daemon', 'help': 'launch as daemon',
'aliases': ['-d', '--daemon']}, 'aliases': ['-d', '--daemon']},
'--server_pid': { '--server-pid': {
'help': 'set PID filename for daemon mode', 'help': 'set PID filename for daemon mode',
'aliases': ['-p', '--pid']}, 'aliases': ['-p', '--pid']},
'--server_hosts': { '--server-hosts': {
'help': 'set server hostnames and ports', 'help': 'set server hostnames and ports',
'aliases': ['-H', '--hosts'], 'aliases': ['-H', '--hosts'],
}, },
'--server_ssl': { '--server-ssl': {
'help': 'use SSL connection', 'help': 'use SSL connection',
'aliases': ['-s', '--ssl'], 'aliases': ['-s', '--ssl'],
}, },
'--server_key': { '--server-key': {
'help': 'set private key file', 'help': 'set private key file',
'aliases': ['-k', '--key'] 'aliases': ['-k', '--key']
}, },
'--server_certificate': { '--server-certificate': {
'help': 'set certificate file', 'help': 'set certificate file',
'aliases': ['-c', '--certificate'] 'aliases': ['-c', '--certificate']
}, },
'--logging_debug': { '--logging-debug': {
'help': 'print debug informations', 'help': 'print debug informations',
'aliases': ['-D', '--debug'] 'aliases': ['-D', '--debug']
} }
@ -73,7 +73,7 @@ def run():
for section, values in config.INITIAL_CONFIG.items(): for section, values in config.INITIAL_CONFIG.items():
group = optparse.OptionGroup(parser, section) group = optparse.OptionGroup(parser, section)
for option, default_value in values.items(): for option, default_value in values.items():
long_name = '--{0}_{1}'.format(section, option) long_name = '--{0}-{1}'.format(section, option)
kwargs = {} kwargs = {}
args = [long_name] args = [long_name]
if default_value.lower() in ('true', 'false'): if default_value.lower() in ('true', 'false'):
@ -117,6 +117,7 @@ def run():
section = group.title section = group.title
for option in group.option_list: for option in group.option_list:
key = option.dest key = option.dest
print(key)
config_key = key.split('_', 1)[1] config_key = key.split('_', 1)[1]
if key: if key:
value = getattr(options, key) value = getattr(options, key)