From 4bd602a245fa642b08074d7225f4d6b1fbaf4e96 Mon Sep 17 00:00:00 2001 From: ldericher Date: Thu, 20 Aug 2020 14:40:49 +0200 Subject: [PATCH] help command --- src/etc/command_help.txt | 47 ++++++++++++++------------------- src/etc/usage.txt | 6 +++++ src/kiwi/_constants.py | 1 + src/kiwi/parser.py | 9 ++++--- src/kiwi/subcommands/config.py | 2 +- src/kiwi/subcommands/disable.py | 2 +- src/kiwi/subcommands/enable.py | 2 +- src/kiwi/subcommands/logs.py | 2 +- src/kiwi/subcommands/purge.py | 2 +- 9 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 src/etc/usage.txt diff --git a/src/etc/command_help.txt b/src/etc/command_help.txt index ea1ecf6..fe27d16 100644 --- a/src/etc/command_help.txt +++ b/src/etc/command_help.txt @@ -1,30 +1,23 @@ -COMMANDS -======== +Commands for Operation: + up Bring up the whole instance, a project or service(s) inside a project + down Bring down the whole instance, a project or service(s) inside a project + update Update the whole instance, a project or service(s) inside a project + clean Cleanly sync all configs to target folder, then relaunch affected projects + purge Remove all running docker artifacts of this instance -# operation +Commands for Instance Management: + config Create or configure kiwi-config instance + inspect Inspect projects in this instance, services inside a project or service(s) inside a project + cmd Run raw docker-compose command in a project -config -up -down -update -clean +Commands for Project and Service Management: + new Create new empty project(s) in this instance + enable Enable project(s) in this instance + disable Disable project(s) in this instance + logs Show logs of a project or service(s) inside a project + shell Spawn shell inside a service inside a project -# management - -new -enable -disable -cmd -purge - -# inspection - -inspect -logs -shell - -# imaging - -build -pull -push +Commands for Image Handling: + build Build images for the whole instance, a project or service(s) inside a project + pull Pull images for the whole instance, a project or service(s) inside a project + push Push images for the whole instance, a project or service(s) inside a project \ No newline at end of file diff --git a/src/etc/usage.txt b/src/etc/usage.txt new file mode 100644 index 0000000..0e25174 --- /dev/null +++ b/src/etc/usage.txt @@ -0,0 +1,6 @@ + + %(prog)s {up,down,update,clean,purge} [ARGS...] + %(prog)s {config,inspect,cmd} [ARGS...] + %(prog)s {new,enable,disable,logs,shell} [ARGS...] + %(prog)s {build,pull,push} [ARGS...] + %(prog)s -h|--help diff --git a/src/kiwi/_constants.py b/src/kiwi/_constants.py index e4bb229..bb6b4cb 100644 --- a/src/kiwi/_constants.py +++ b/src/kiwi/_constants.py @@ -20,6 +20,7 @@ DEFAULT_KIWI_CONF_NAME = f"{KIWI_ROOT}/etc/kiwi_default.yml" VERSION_TAG_NAME = f"{KIWI_ROOT}/etc/version_tag" DEFAULT_DOCKER_COMPOSE_NAME = f"{KIWI_ROOT}/etc/docker-compose_default.yml" COMMAND_HELP_TEXT_NAME = f"{KIWI_ROOT}/etc/command_help.txt" +USAGE_TEXT_NAME = f"{KIWI_ROOT}/etc/usage.txt" # special config directory in projects CONF_DIRECTORY_NAME = 'conf' diff --git a/src/kiwi/parser.py b/src/kiwi/parser.py index a54bb05..88114fa 100644 --- a/src/kiwi/parser.py +++ b/src/kiwi/parser.py @@ -2,7 +2,7 @@ import argparse # local -from ._constants import COMMAND_HELP_TEXT_NAME +from ._constants import COMMAND_HELP_TEXT_NAME, USAGE_TEXT_NAME class Parser: @@ -19,12 +19,15 @@ class Parser: def __init__(self): # add version data from separate file (keeps default config cleaner) with open(COMMAND_HELP_TEXT_NAME, 'r') as stream: - command_help_text = stream.read().strip() + command_help_text = stream.read() + + with open(USAGE_TEXT_NAME, 'r') as stream: + usage_text = stream.read() # create main parser self.__parser = argparse.ArgumentParser( description='kiwi-config', - usage='%(prog)s [command]', + usage=usage_text, epilog=command_help_text, ) self.__parser.formatter_class = argparse.RawDescriptionHelpFormatter diff --git a/src/kiwi/subcommands/config.py b/src/kiwi/subcommands/config.py index 1174a3b..15f3c9c 100644 --- a/src/kiwi/subcommands/config.py +++ b/src/kiwi/subcommands/config.py @@ -15,7 +15,7 @@ class ConfigCommand(SubCommand): super().__init__( 'config', action=f"Configuring '{KIWI_CONF_NAME}' in", - description="Configure kiwi-config instance" + description="Create or configure kiwi-config instance" ) # -f switch: Initialize with default config diff --git a/src/kiwi/subcommands/disable.py b/src/kiwi/subcommands/disable.py index 9715c27..c10eec9 100644 --- a/src/kiwi/subcommands/disable.py +++ b/src/kiwi/subcommands/disable.py @@ -9,7 +9,7 @@ class DisableCommand(ProjectCommand): super().__init__( 'disable', num_projects='+', action="Disabling", - description="Disable whole project(s) in this instance" + description="Disable project(s) in this instance" ) def _run_projects(self, runner, args, projects): diff --git a/src/kiwi/subcommands/enable.py b/src/kiwi/subcommands/enable.py index cf4079e..730fb69 100644 --- a/src/kiwi/subcommands/enable.py +++ b/src/kiwi/subcommands/enable.py @@ -9,7 +9,7 @@ class EnableCommand(ProjectCommand): super().__init__( 'enable', num_projects='+', action="Enabling", - description="Enable whole project(s) in this instance" + description="Enable project(s) in this instance" ) def _run_projects(self, runner, args, projects): diff --git a/src/kiwi/subcommands/logs.py b/src/kiwi/subcommands/logs.py index b2d49b7..2407220 100644 --- a/src/kiwi/subcommands/logs.py +++ b/src/kiwi/subcommands/logs.py @@ -9,7 +9,7 @@ class LogsCommand(ServiceCommand): super().__init__( 'logs', num_projects=1, num_services='*', action="Showing logs of", - description="Show logs of a project or service(s) of a project" + description="Show logs of a project or service(s) inside a project" ) # -f switch: Follow logs diff --git a/src/kiwi/subcommands/purge.py b/src/kiwi/subcommands/purge.py index fbf771b..2200302 100644 --- a/src/kiwi/subcommands/purge.py +++ b/src/kiwi/subcommands/purge.py @@ -17,7 +17,7 @@ class PurgeCommand(SubCommand): super().__init__( 'purge', action="Tearing down", - description="Remove all ephemeral artifacts of this instance" + description="Remove all running docker artifacts of this instance" ) def _run_instance(self, runner, args):