diff --git a/src/soluble/conf.py b/src/soluble/conf.py index 0483ad9..0e90d5c 100644 --- a/src/soluble/conf.py +++ b/src/soluble/conf.py @@ -58,8 +58,7 @@ "ssh_target": { "positional": True, "display_priority": 0, - # TODO only for subcommands, not for the main command - "subcommands": ["minion"], + "subcommands": [], "help": "Target for the salt-ssh command. This is typically a minion ID, wildcard, or grain.", }, "salt_config_dir": {}, diff --git a/src/soluble/soluble/init.py b/src/soluble/soluble/init.py index d61a9cf..547cdeb 100644 --- a/src/soluble/soluble/init.py +++ b/src/soluble/soluble/init.py @@ -1,4 +1,5 @@ from soluble.conf import CLI_CONFIG +from soluble.conf import SUBCOMMANDS def __init__(hub): @@ -29,6 +30,15 @@ def cli(hub): """ Parse the config data and pass it to the actual runtime """ + soluble_plugins = list(hub.soluble._loaded.keys() - {"init"}) + + # Dynamically add ssh_target to every subcommand + CLI_CONFIG["ssh_target"]["subcommands"] = soluble_plugins + + # Dynamically create a subcommand for every soluble plugin + for plugin in soluble_plugins: + SUBCOMMANDS[plugin] = {"help": f"Create an ephemeral {plugin}"} + hub.pop.config.load(["soluble"], cli="soluble") kwargs = dict(hub.OPT.soluble) salt_ssh_opts = [] diff --git a/src/soluble_minion/conf.py b/src/soluble_minion/conf.py index 7577702..e1e2fcf 100644 --- a/src/soluble_minion/conf.py +++ b/src/soluble_minion/conf.py @@ -25,7 +25,4 @@ }, } - -SUBCOMMANDS = {"minion": {"help": "Create an ephemeral minion", "dyne": "soluble"}} - DYNE = {"soluble": ["soluble"]}