main: Switch to subcommands
- show-deps replaced with 'mopidy deps' - show-config replaced with 'mopidy config' - Just running mopidy now displays help, run 'mopidy run' to start server.
This commit is contained in:
parent
f49973304c
commit
9539c2ac35
@ -31,9 +31,18 @@ def main():
|
||||
signal.signal(signal.SIGUSR1, pykka.debug.log_thread_tracebacks)
|
||||
|
||||
parser = commands.build_parser()
|
||||
subparser = parser.add_subparsers(title='commands', metavar='COMMAND')
|
||||
|
||||
run_parser = subparser.add_parser('run', help='start mopidy server')
|
||||
run_parser.set_defaults(command='run')
|
||||
config_parser = subparser.add_parser('config', help='show current config')
|
||||
config_parser.set_defaults(command='config')
|
||||
deps_parser = subparser.add_parser('deps', help='show dependencies')
|
||||
deps_parser.set_defaults(command='deps')
|
||||
|
||||
args = parser.parse_args(args=mopidy_args)
|
||||
|
||||
if args.show_deps or args.show_config:
|
||||
if args.command in ('config', 'deps'):
|
||||
args.verbosity_level -= 1
|
||||
|
||||
bootstrap_logging(args)
|
||||
@ -61,13 +70,12 @@ def main():
|
||||
|
||||
log_extension_info(installed_extensions, enabled_extensions)
|
||||
|
||||
# TODO: move to 'mopidy config' and 'mopidy deps'
|
||||
if args.show_config:
|
||||
if args.command == 'config':
|
||||
logger.info('Dumping sanitized user config and exiting.')
|
||||
print config_lib.format(
|
||||
config, installed_extensions, config_errors)
|
||||
sys.exit(0)
|
||||
if args.show_deps:
|
||||
elif args.command == 'deps':
|
||||
logger.info('Dumping debug info about dependencies and exiting.')
|
||||
print deps.format_dependency_list()
|
||||
sys.exit(0)
|
||||
|
||||
@ -37,14 +37,6 @@ def build_parser():
|
||||
'--save-debug-log',
|
||||
action='store_true', dest='save_debug_log',
|
||||
help='save debug log to "./mopidy.log"')
|
||||
parser.add_argument(
|
||||
'--show-config',
|
||||
action='store_true', dest='show_config',
|
||||
help='show current config')
|
||||
parser.add_argument(
|
||||
'--show-deps',
|
||||
action='store_true', dest='show_deps',
|
||||
help='show dependencies and their versions')
|
||||
parser.add_argument(
|
||||
'--config',
|
||||
action='store', dest='config_files', type=config_files_type,
|
||||
|
||||
@ -22,6 +22,5 @@ class HelpTest(unittest.TestCase):
|
||||
self.assertIn('--quiet', output)
|
||||
self.assertIn('--verbose', output)
|
||||
self.assertIn('--save-debug-log', output)
|
||||
self.assertIn('--show-config', output)
|
||||
self.assertIn('--config', output)
|
||||
self.assertIn('--option', output)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user