From fd681418f59ee8af1f359c0cb48a7b554eccd997 Mon Sep 17 00:00:00 2001 From: ldericher Date: Wed, 19 Aug 2020 16:23:52 +0200 Subject: [PATCH] action strings everywhere --- src/kiwi/subcommands/_subcommand.py | 14 ++++---------- src/kiwi/subcommands/conf.py | 3 +++ src/kiwi/subcommands/init.py | 1 + src/kiwi/subcommands/net.py | 3 ++- src/kiwi/subcommands/sh.py | 1 + src/kiwi/subcommands/show.py | 1 + 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/kiwi/subcommands/_subcommand.py b/src/kiwi/subcommands/_subcommand.py index 9566443..dccb00d 100644 --- a/src/kiwi/subcommands/_subcommand.py +++ b/src/kiwi/subcommands/_subcommand.py @@ -19,7 +19,7 @@ class SubCommand: _action = None - def __init__(self, name, action='', add_parser=True, **kwargs): + def __init__(self, name, action, add_parser=True, **kwargs): self.__name = name if add_parser: self._sub_parser = Parser().get_subparsers().add_parser( @@ -27,12 +27,6 @@ class SubCommand: **kwargs ) - if not action: - # default action string - self._action = f"Running '{str(self)}' for" - else: - self._action = action - def __str__(self): return self.__name @@ -50,7 +44,7 @@ class SubCommand: class ProjectCommand(SubCommand): """this command concerns a project in current instance""" - def __init__(self, name, num_projects, action='', add_parser=True, **kwargs): + def __init__(self, name, num_projects, action, add_parser=True, **kwargs): super().__init__( name, action=action, add_parser=add_parser, **kwargs @@ -88,7 +82,7 @@ class ProjectCommand(SubCommand): class ServiceCommand(ProjectCommand): """this command concerns service(s) in a project""" - def __init__(self, name, num_projects, num_services, action='', add_parser=True, **kwargs): + def __init__(self, name, num_projects, num_services, action, add_parser=True, **kwargs): super().__init__( name, num_projects=num_projects, action=action, add_parser=add_parser, **kwargs @@ -96,7 +90,7 @@ class ServiceCommand(ProjectCommand): if (isinstance(num_projects, str) and num_projects == '*') \ or (isinstance(num_projects, int) and num_projects > 1): - logging.warning(f"Invalid choice for project count: {num_projects}") + raise ValueError(f"Invalid choice for project count: {num_projects}") if num_services == 1: services = "a service" diff --git a/src/kiwi/subcommands/conf.py b/src/kiwi/subcommands/conf.py index b3d511f..3030b98 100644 --- a/src/kiwi/subcommands/conf.py +++ b/src/kiwi/subcommands/conf.py @@ -19,6 +19,7 @@ class ConfCopyCommand(SubCommand): def __init__(self): super().__init__( 'conf-copy', + action="Syncing all configs for", description="Synchronize all config files to target directory" ) @@ -46,6 +47,7 @@ class ConfPurgeCommand(SubCommand): def __init__(self): super().__init__( 'conf-purge', + action="Removing all configs for", description="Remove all config files in target directory" ) @@ -66,6 +68,7 @@ class ConfCleanCommand(SubCommand): def __init__(self): super().__init__( 'conf-clean', + action="Cleaning all configs for", description="Cleanly sync all configs to target folder, relaunch affected projects" ) diff --git a/src/kiwi/subcommands/init.py b/src/kiwi/subcommands/init.py index 53ed9e3..5f9298a 100644 --- a/src/kiwi/subcommands/init.py +++ b/src/kiwi/subcommands/init.py @@ -31,6 +31,7 @@ class InitCommand(SubCommand): def __init__(self): super().__init__( 'init', + action="Creating", description="Create a new kiwi-config instance" ) diff --git a/src/kiwi/subcommands/net.py b/src/kiwi/subcommands/net.py index e83f513..63236fc 100644 --- a/src/kiwi/subcommands/net.py +++ b/src/kiwi/subcommands/net.py @@ -27,7 +27,7 @@ class NetUpCommand(SubCommand): def __init__(self): super().__init__( 'net-up', - action="Creating the local network hub", + action="Creating the local network hub for", description="Create the local network hub for this instance" ) @@ -63,6 +63,7 @@ class NetDownCommand(SubCommand): def __init__(self): super().__init__( 'net-down', + action="Removing the local network hub for", description="Remove the local network hub for this instance" ) diff --git a/src/kiwi/subcommands/sh.py b/src/kiwi/subcommands/sh.py index c945d42..bf1d586 100644 --- a/src/kiwi/subcommands/sh.py +++ b/src/kiwi/subcommands/sh.py @@ -76,6 +76,7 @@ class ShCommand(ServiceCommand): def __init__(self): super().__init__( 'sh', num_projects=1, num_services=1, + action="Spawning shell in", description="Spawn shell inside a project's service" ) diff --git a/src/kiwi/subcommands/show.py b/src/kiwi/subcommands/show.py index 99834df..1aed901 100644 --- a/src/kiwi/subcommands/show.py +++ b/src/kiwi/subcommands/show.py @@ -11,6 +11,7 @@ class ShowCommand(SubCommand): def __init__(self): super().__init__( 'show', + action="Printing", description="Show effective kiwi.yml" )