diff --git a/src/kiwi/subcommands/net.py b/src/kiwi/subcommands/net.py index 6908285..63718b6 100644 --- a/src/kiwi/subcommands/net.py +++ b/src/kiwi/subcommands/net.py @@ -5,6 +5,7 @@ import subprocess # local from ._subcommand import SubCommand from .utils.dockercommand import DockerCommand +from .utils.user_input import are_you_sure def _find_net(config, args): @@ -65,12 +66,15 @@ class NetDownCommand(SubCommand): return try: - 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 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") except subprocess.CalledProcessError: logging.error(f"Error removing network '{config['network:name']}'") \ No newline at end of file diff --git a/src/kiwi/subcommands/up.py b/src/kiwi/subcommands/up.py index f3e3753..adc50d2 100644 --- a/src/kiwi/subcommands/up.py +++ b/src/kiwi/subcommands/up.py @@ -4,7 +4,7 @@ import logging # local from ._subcommand import ServiceCommand from .utils.dockercommand import DockerCommand -from .utils.project import list_projects +from .utils.project import get_project_name, list_projects class UpCommand(ServiceCommand): @@ -13,20 +13,23 @@ class UpCommand(ServiceCommand): def __init__(self): super().__init__( 'up', num_projects='?', num_services='*', - description="Start the whole instance, a project or service(s) inside a project" + description="Bring up the whole instance, a project or service(s) inside a project" ) def run(self, runner, config, args): - if args.projects is None: + if 'projects' not in args or args.projects is None: # "up" for all projects for project_name in list_projects(config): - logging.info(f"Bringing up project '{project_name}'") args.projects = project_name - runner.run('up') return + if 'services' in args and args.services: + logging.info(f"Bringing up services {args.services} in project '{get_project_name(args)}'") + 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]