From 9781d7f77b0eb82b57520d759781695d59ffcc00 Mon Sep 17 00:00:00 2001 From: novirium Date: Mon, 8 Jun 2020 19:25:13 +0800 Subject: [PATCH] Click fix --- shepherd/core.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/shepherd/core.py b/shepherd/core.py index 916d8fb..d9cf5b2 100644 --- a/shepherd/core.py +++ b/shepherd/core.py @@ -169,30 +169,29 @@ def compile_config(default_config_path): return core_conf, plugin_classes, plugin_configs -@click.group(invoke_without_command = True) +@click.group(invoke_without_command=True) #help="Path to default config TOML file" - @click.argument('default_config', default="shepherd-default.toml", type=click.Path()) @click.pass_context def cli(ctx, default_config): """ Core service. Expects the default config to be set as an argument. """ - #argparser = argparse.ArgumentParser(description="Keep track of a mob " + # argparser = argparse.ArgumentParser(description="Keep track of a mob " # "of roaming Pis") - #argparser.add_argument("configfile", nargs='?', metavar="configfile", + # argparser.add_argument("configfile", nargs='?', metavar="configfile", # help="Path to configfile", default="shepherd.toml") - #argparser.add_argument( + # argparser.add_argument( # '-e', '--noedit', help="Disable the editable config temporarily", action="store_true", default=False) - #argparser.add_argument("-t", "--test", help="Test and interface function of the from 'plugin:function'", + # argparser.add_argument("-t", "--test", help="Test and interface function of the from 'plugin:function'", # default=None) #args = argparser.parse_args() core_conf, plugin_classes, plugin_configs = compile_config(default_config) - if args.test is None: - control.init_control(core_conf, plugin_configs) + # if args.test is None: + # control.init_control(core_conf, plugin_configs) scheduler.init_scheduler(core_conf) plugin.init_plugins(plugin_classes, plugin_configs, core_conf) @@ -209,11 +208,11 @@ def cli(ctx, default_config): except (KeyboardInterrupt, SystemExit): pass + @click.argument('plugin_function') @cli.command() -def test(): - if args.test is not None: - (test_plugin, test_func) = args.test.split(':') - func = getattr(shepherd.plugin.plugin_functions[test_plugin], test_func) - print(func()) - return \ No newline at end of file +def test(plugin_function): + (test_plugin, test_func) = plugin_function.split(':') + func = getattr(plugin.plugin_functions[test_plugin], test_func) + print(func()) + return