From 934a1bd15e2f5c11ad759423f53c645e33ad5b02 Mon Sep 17 00:00:00 2001 From: ldericher Date: Thu, 20 Aug 2020 15:29:07 +0200 Subject: [PATCH] kiwi help --- .../hello-world.project/docker-compose.yml | 6 +++- src/etc/command_help.txt | 32 +++++++++---------- src/etc/docker-compose_default.yml | 2 +- src/etc/kiwi_help.txt | 9 ++++++ src/etc/usage.txt | 6 ---- src/kiwi/_constants.py | 2 +- src/kiwi/parser.py | 11 +++---- 7 files changed, 37 insertions(+), 31 deletions(-) create mode 100644 src/etc/kiwi_help.txt delete mode 100644 src/etc/usage.txt diff --git a/example/hello-world.project/docker-compose.yml b/example/hello-world.project/docker-compose.yml index 6d66369..35951b8 100644 --- a/example/hello-world.project/docker-compose.yml +++ b/example/hello-world.project/docker-compose.yml @@ -7,12 +7,16 @@ networks: # interconnects projects kiwi_hub: external: - name: $KIWI_HUB_NAME + name: ${KIWI_HUB_NAME} services: hello-world: image: alpine:latest command: sh -c 'LOOP=1; while :; do echo Hello World "$$LOOP"; LOOP=$$(($$LOOP + 1)); sleep 10; done' + networks: + - default + - kiwi_hub + foo-bar: image: alpine:latest command: sh -c 'LOOP=1; while :; do echo Foo Bar "$$LOOP"; LOOP=$$(($$LOOP + 1)); sleep 20; done' diff --git a/src/etc/command_help.txt b/src/etc/command_help.txt index fe27d16..51ae022 100644 --- a/src/etc/command_help.txt +++ b/src/etc/command_help.txt @@ -1,23 +1,23 @@ 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 + 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 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 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 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 + 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 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 + 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/docker-compose_default.yml b/src/etc/docker-compose_default.yml index 3baa9e3..47f85e4 100644 --- a/src/etc/docker-compose_default.yml +++ b/src/etc/docker-compose_default.yml @@ -7,7 +7,7 @@ networks: # interconnects projects kiwi_hub: external: - name: $KIWI_HUB_NAME + name: ${KIWI_HUB_NAME} services: # an example service diff --git a/src/etc/kiwi_help.txt b/src/etc/kiwi_help.txt new file mode 100644 index 0000000..e08f116 --- /dev/null +++ b/src/etc/kiwi_help.txt @@ -0,0 +1,9 @@ +kiwi-config is the tool for container server management. + +Features: + - Group your services into projects using their own docker-compose.yml + - Bind to file system by using ${TARGETDIR} as volume in docker-compose.yml + - Add instance-global config files by using ${CONFDIR} as volume in docker-compose.yml + - Add instance-global custom values inside docker-compose.yml using config:runtime:env + - Build service-specific, private docker images from Dockerfiles + - Check full instances into any version control system diff --git a/src/etc/usage.txt b/src/etc/usage.txt deleted file mode 100644 index 0e25174..0000000 --- a/src/etc/usage.txt +++ /dev/null @@ -1,6 +0,0 @@ - - %(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 bb6b4cb..11726b0 100644 --- a/src/kiwi/_constants.py +++ b/src/kiwi/_constants.py @@ -19,8 +19,8 @@ HEADER_KIWI_CONF_NAME = f"{KIWI_ROOT}/etc/kiwi_header.yml" 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" +KIWI_HELP_TEXT_NAME = f"{KIWI_ROOT}/etc/kiwi_help.txt" 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 88114fa..d8c1e71 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, USAGE_TEXT_NAME +from ._constants import COMMAND_HELP_TEXT_NAME, KIWI_HELP_TEXT_NAME class Parser: @@ -18,16 +18,15 @@ class Parser: def __init__(self): # add version data from separate file (keeps default config cleaner) + with open(KIWI_HELP_TEXT_NAME, 'r') as stream: + kiwi_help = stream.read() + with open(COMMAND_HELP_TEXT_NAME, 'r') as stream: 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=usage_text, + description=kiwi_help, epilog=command_help_text, ) self.__parser.formatter_class = argparse.RawDescriptionHelpFormatter