From 1e3b1d9f9545d8ee4c8ecc780a11bd1ba2c5ad7f Mon Sep 17 00:00:00 2001 From: dazz Date: Wed, 17 Jan 2024 09:34:05 +0100 Subject: [PATCH] update create arg --- README.md | 22 +++++++++------------- cmd/s6cli/main.go | 22 ++++++++-------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b6867a5..741411f 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ Creates a docker image with the cli installed make docker ``` +or if you pulled the image from dockerhub +```bash +docker run -it --rm -v ./examples/s6-overlay:/etc/s6-overlay hakindazz/s6-cli:latest +``` + + ### In Dockerfile If you want to use the cli in a Dockerfile you can copy it from the docker image ```dockerfile @@ -50,8 +56,8 @@ There is a help command that you can use to get more info about the commands in ```bash ./s6-cli help ``` -### The option `--rootPath {path}, -p {path}` -All commands need the `rootPath` to be specified. It must point to the directory where services will be defined. +### The option `--root-path {path}, -p {path}` +All commands need the `root-path` to be specified. It must point to the directory where services will be defined. Default is set to `/etc/s6-overlay/s6-rc.d` ### Create @@ -59,7 +65,7 @@ There are three types of services that can be created: Oneshot, Longrun and Bund Read more about them [here](https://skarnet.org/software/s6-rc/s6-rc-compile.html) ```bash -./s6-cli --rootPath {path} create {o|l|b} {service} +./s6-cli --root-path {path} create {oneshot|longrun|bundle} {service} ``` ### Remove @@ -76,7 +82,6 @@ If the service is not needed anymore it can be removed with the following comman ``` - ### Mermaid This command will generate a mermaid graph of the services. @@ -108,12 +113,3 @@ graph TD; nginx --> php-fpm php-fpm --> create-directories ``` - - -## todo -* create dependencies between services -* add `s6-cli update` command -* add `s6-cli init` command -* add `s6-cli ci` command -* style output with color https://github.com/charmbracelet/glamour -* tui with https://github.com/charmbracelet/bubbletea \ No newline at end of file diff --git a/cmd/s6cli/main.go b/cmd/s6cli/main.go index e627468..152cca0 100644 --- a/cmd/s6cli/main.go +++ b/cmd/s6cli/main.go @@ -20,7 +20,7 @@ func main() { rootPath := "/etc/s6-overlay/s6-rc.d" app := &cli.App{ Name: "s6-cli", - Version: "0.0.2", + Version: "v0.2.0", Compiled: time.Now(), Authors: []*cli.Author{ { @@ -58,7 +58,8 @@ func main() { } if execute != "" { fmt.Println("s6-cli: lint found issues with services in " + rootPath) - return errors.New(execute) + fmt.Println(execute) + return nil } fmt.Println("s6-cli: lint found no issues") return nil @@ -89,7 +90,7 @@ func main() { Name: "create", Aliases: []string{"c"}, Usage: "create a service", - ArgsUsage: "[type: (o|l|b)] [id]", + ArgsUsage: " ", Flags: []cli.Flag{ &cli.BoolFlag{Value: false, Name: "overwrite", Aliases: []string{"o"}, Usage: "Ignore existing files and directories"}, }, @@ -98,16 +99,9 @@ func main() { rootPath = cCtx.String("root-path") } - var serviceType service.Type - switch t := cCtx.Args().Get(0); t { - case "o": - serviceType = service.TypeOneshot - case "l": - serviceType = service.TypeLongrun - case "b": - serviceType = service.TypeBundle - default: - fmt.Print("Arg type must not be empty and one of 'o', 'l' or 'b'\n") + var serviceType = service.Type(cCtx.Args().Get(0)) + if service.ValidType(serviceType) == false { + fmt.Println("Argument type be one of 'oneshot', 'longrun' or 'bundle'") os.Exit(1) } @@ -115,7 +109,7 @@ func main() { if idArg := cCtx.Args().Get(1); idArg != "" { id = service.Id(idArg) } else { - fmt.Println("Arg idArg must not be empty") + fmt.Println("Argument id must not be empty") os.Exit(1) }