From 6b1583805967d31db092e0048fba4132707cdffd Mon Sep 17 00:00:00 2001 From: jpic Date: Sat, 18 Apr 2020 20:46:47 +0200 Subject: [PATCH] Guess who's going out of the rabbithole --- shlax/cli.py | 35 +++++++++++++++++++++++++---------- shlax/targets/docker.py | 2 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/shlax/cli.py b/shlax/cli.py index 1596b22..74baa75 100644 --- a/shlax/cli.py +++ b/shlax/cli.py @@ -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( diff --git a/shlax/targets/docker.py b/shlax/targets/docker.py index ef1c68c..4275493 100644 --- a/shlax/targets/docker.py +++ b/shlax/targets/docker.py @@ -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():