diff --git a/src/kiwi/runner.py b/src/kiwi/runner.py index 186029b..d84cca1 100644 --- a/src/kiwi/runner.py +++ b/src/kiwi/runner.py @@ -36,13 +36,14 @@ class Runner: logging.debug(f"Running '{cmd}' with args: {args}") try: - cmd.run(self, LoadedConfig.get(), args) + result = cmd.run(self, LoadedConfig.get(), args) except KeyboardInterrupt: print() logging.warning(f"'{cmd}' aborted, inputs may have been discarded.") + result = False - return True + return result # command not found logging.error(f"kiwi command '{command}' unknown") diff --git a/src/kiwi/subcommands/cmd.py b/src/kiwi/subcommands/cmd.py index a935880..3182f11 100644 --- a/src/kiwi/subcommands/cmd.py +++ b/src/kiwi/subcommands/cmd.py @@ -23,3 +23,5 @@ class CmdCommand(ProjectCommand): # run with split compose_cmd argument DockerCommand('docker-compose').run(config, args, shlex.split(args.compose_cmd)) + + return True diff --git a/src/kiwi/subcommands/down.py b/src/kiwi/subcommands/down.py index d931cc3..790f3bb 100644 --- a/src/kiwi/subcommands/down.py +++ b/src/kiwi/subcommands/down.py @@ -24,9 +24,10 @@ class DownCommand(ServiceCommand): for project_name in list_projects(config): args.projects = project_name runner.run('down') - return + else: + return False - if 'services' in args and args.services: + elif 'services' in args and args.services: # "down" for service(s) inside project logging.info(f"Bringing down services {args.services} in project '{get_project_name(args)}'") @@ -44,3 +45,5 @@ class DownCommand(ServiceCommand): DockerCommand('docker-compose').run( config, args, ['down'] ) + + return True diff --git a/src/kiwi/subcommands/init.py b/src/kiwi/subcommands/init.py index cec8dd3..e82240e 100644 --- a/src/kiwi/subcommands/init.py +++ b/src/kiwi/subcommands/init.py @@ -65,3 +65,4 @@ class InitCommand(SubCommand): user_input(config, 'network:cidr', "Enter CIDR block for local docker network") config.save() + return True diff --git a/src/kiwi/subcommands/logs.py b/src/kiwi/subcommands/logs.py index 5a22912..a60122f 100644 --- a/src/kiwi/subcommands/logs.py +++ b/src/kiwi/subcommands/logs.py @@ -35,3 +35,5 @@ class LogsCommand(ServiceCommand): DockerCommand('docker-compose').run(config, args, compose_cmd) else: DockerCommand('docker-compose').run_less(config, args, compose_cmd) + + return True diff --git a/src/kiwi/subcommands/net.py b/src/kiwi/subcommands/net.py index 63718b6..3eb801e 100644 --- a/src/kiwi/subcommands/net.py +++ b/src/kiwi/subcommands/net.py @@ -31,7 +31,7 @@ class NetUpCommand(SubCommand): def run(self, runner, config, args): if _find_net(config, args): logging.info(f"Network '{config['network:name']}' already exists") - return + return True try: DockerCommand('docker').run( @@ -49,6 +49,9 @@ class NetUpCommand(SubCommand): except subprocess.CalledProcessError: logging.error(f"Error creating network '{config['network:name']}'") + return False + + return True class NetDownCommand(SubCommand): @@ -63,18 +66,22 @@ class NetDownCommand(SubCommand): def run(self, runner, config, args): if not _find_net(config, args): logging.info(f"Network '{config['network:name']}' already removed") - return + return True try: if are_you_sure("This will bring down this instance's hub network!"): - runner.run('down') - - DockerCommand('docker').run( - config, args, - ['network', 'rm', config['network:name']], - check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL - ) - logging.info(f"Network '{config['network:name']}' removed") + if runner.run('down'): + DockerCommand('docker').run( + config, args, + ['network', 'rm', config['network:name']], + check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL + ) + logging.info(f"Network '{config['network:name']}' removed") + else: + return False except subprocess.CalledProcessError: - logging.error(f"Error removing network '{config['network:name']}'") \ No newline at end of file + logging.error(f"Error removing network '{config['network:name']}'") + return False + + return True \ No newline at end of file diff --git a/src/kiwi/subcommands/sh.py b/src/kiwi/subcommands/sh.py index 17d5ca8..7e3d31e 100644 --- a/src/kiwi/subcommands/sh.py +++ b/src/kiwi/subcommands/sh.py @@ -91,3 +91,6 @@ class ShCommand(ServiceCommand): DockerCommand('docker-compose').run( config, args, [*compose_cmd, shell] ) + return True + + return False diff --git a/src/kiwi/subcommands/show.py b/src/kiwi/subcommands/show.py index 9b65da4..4448734 100644 --- a/src/kiwi/subcommands/show.py +++ b/src/kiwi/subcommands/show.py @@ -13,3 +13,4 @@ class ShowCommand(SubCommand): def run(self, runner, config, args): print(config) + return True diff --git a/src/kiwi/subcommands/up.py b/src/kiwi/subcommands/up.py index adc50d2..0681d83 100644 --- a/src/kiwi/subcommands/up.py +++ b/src/kiwi/subcommands/up.py @@ -30,7 +30,10 @@ class UpCommand(ServiceCommand): else: logging.info(f"Bringing up project '{get_project_name(args)}'") - runner.run('net-up') - DockerCommand('docker-compose').run( - config, args, ['up', '-d', *args.services] - ) + if runner.run('net-up'): + DockerCommand('docker-compose').run( + config, args, ['up', '-d', *args.services] + ) + return True + + return False