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: else:
for name, method in value.steps().items(): for name, step in value.steps().items():
self[modname][name] = cli2.Callable( if isinstance(step, Action):
modname, self[modname][name] = cli2.Callable(
self.action(value), modname,
doc=inspect.getdoc(method), self.action(step),
options={ doc=inspect.getdoc(step),
option: cli2.Option(option, **cfg) options={
for option, cfg in value.options.items() 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: else:
if len(value.steps()) == 1: if len(value.steps()) == 1:
self[modname][key] = cli2.Callable( self[modname][key] = cli2.Callable(

View File

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