Guess who's going out of the rabbithole

This commit is contained in:
jpic 2020-04-18 20:46:47 +02:00
parent 85e11755f7
commit 6b15838059
2 changed files with 26 additions and 11 deletions

View File

@ -116,16 +116,31 @@ class ConsoleScript(cli2.ConsoleScript):
}
)
else:
for name, method in value.steps().items():
self[modname][name] = cli2.Callable(
modname,
self.action(value),
doc=inspect.getdoc(method),
options={
option: cli2.Option(option, **cfg)
for option, cfg in value.options.items()
}
)
for name, step in value.steps().items():
if isinstance(step, Action):
self[modname][name] = cli2.Callable(
modname,
self.action(step),
doc=inspect.getdoc(step),
options={
option: cli2.Option(option, **cfg)
for option, cfg in value.options.items()
}
)
else:
# should be a method, just clone the
# original action and replace default_steps
action = copy.deepcopy(value)
action.default_steps = [name]
self[modname][name] = cli2.Callable(
modname,
self.action(action),
doc=inspect.getdoc(step),
options={
option: cli2.Option(option, **cfg)
for option, cfg in value.options.items()
}
)
else:
if len(value.steps()) == 1:
self[modname][key] = cli2.Callable(

View File

@ -9,6 +9,7 @@ from .localhost import Localhost
class Docker(Localhost):
"""Manage a docker container."""
default_steps = ['install', 'up']
contextualize = ['image', 'home']
def __init__(self, *args, **kwargs):
self.image = kwargs.get('image', 'alpine')
@ -53,7 +54,6 @@ class Docker(Localhost):
# )
# ).out.split('\n')[0]
if step('install') and 'install' in self.kwargs:
breakpoint()
await self.action(self.kwargs['install'], *args, **kwargs)
if step('rm') and await self.exists():