main: Move argparse building to a function.
This commit is contained in:
parent
5b78ff94ff
commit
bdba83b1be
@ -30,7 +30,9 @@ def main():
|
|||||||
signal.signal(signal.SIGTERM, process.exit_handler)
|
signal.signal(signal.SIGTERM, process.exit_handler)
|
||||||
signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)
|
signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)
|
||||||
|
|
||||||
args = commands.parser.parse_args(args=mopidy_args)
|
parser = commands.build_parser()
|
||||||
|
args = parser.parse_args(args=mopidy_args)
|
||||||
|
|
||||||
if args.show_config:
|
if args.show_config:
|
||||||
commands.show_config(args)
|
commands.show_config(args)
|
||||||
if args.show_deps:
|
if args.show_deps:
|
||||||
|
|||||||
@ -21,39 +21,42 @@ def config_override_type(value):
|
|||||||
'%s must have the format section/key=value' % value)
|
'%s must have the format section/key=value' % value)
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
def build_parser():
|
||||||
parser.add_argument(
|
parser = argparse.ArgumentParser()
|
||||||
'--version', action='version',
|
parser.add_argument(
|
||||||
version='Mopidy %s' % versioning.get_version())
|
'--version', action='version',
|
||||||
parser.add_argument(
|
version='Mopidy %s' % versioning.get_version())
|
||||||
'-q', '--quiet',
|
parser.add_argument(
|
||||||
action='store_const', const=-1, dest='verbosity_level',
|
'-q', '--quiet',
|
||||||
help='less output (warning level)')
|
action='store_const', const=-1, dest='verbosity_level',
|
||||||
parser.add_argument(
|
help='less output (warning level)')
|
||||||
'-v', '--verbose',
|
parser.add_argument(
|
||||||
action='count', dest='verbosity_level',
|
'-v', '--verbose',
|
||||||
help='more output (debug level)')
|
action='count', dest='verbosity_level',
|
||||||
parser.add_argument(
|
help='more output (debug level)')
|
||||||
'--save-debug-log',
|
parser.add_argument(
|
||||||
action='store_true', dest='save_debug_log',
|
'--save-debug-log',
|
||||||
help='save debug log to "./mopidy.log"')
|
action='store_true', dest='save_debug_log',
|
||||||
parser.add_argument(
|
help='save debug log to "./mopidy.log"')
|
||||||
'--show-config',
|
parser.add_argument(
|
||||||
action='store_true', dest='show_config',
|
'--show-config',
|
||||||
help='show current config')
|
action='store_true', dest='show_config',
|
||||||
parser.add_argument(
|
help='show current config')
|
||||||
'--show-deps',
|
parser.add_argument(
|
||||||
action='store_true', dest='show_deps',
|
'--show-deps',
|
||||||
help='show dependencies and their versions')
|
action='store_true', dest='show_deps',
|
||||||
parser.add_argument(
|
help='show dependencies and their versions')
|
||||||
'--config',
|
parser.add_argument(
|
||||||
action='store', dest='config_files', type=config_files_type,
|
'--config',
|
||||||
default=b'$XDG_CONFIG_DIR/mopidy/mopidy.conf',
|
action='store', dest='config_files', type=config_files_type,
|
||||||
help='config files to use, colon seperated, later files override')
|
default=b'$XDG_CONFIG_DIR/mopidy/mopidy.conf',
|
||||||
parser.add_argument(
|
help='config files to use, colon seperated, later files override')
|
||||||
'-o', '--option',
|
parser.add_argument(
|
||||||
action='append', dest='config_overrides', type=config_override_type,
|
'-o', '--option',
|
||||||
help='`section/key=value` values to override config options')
|
action='append', dest='config_overrides', type=config_override_type,
|
||||||
|
help='`section/key=value` values to override config options')
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def show_config(args):
|
def show_config(args):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user