Skip to content

Commit

Permalink
update create arg
Browse files Browse the repository at this point in the history
  • Loading branch information
dazz committed Jan 17, 2024
1 parent cc5e2ce commit 1e3b1d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,16 +56,16 @@ 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
There are three types of services that can be created: Oneshot, Longrun and Bundle.
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
Expand All @@ -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.

Expand Down Expand Up @@ -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
22 changes: 8 additions & 14 deletions cmd/s6cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -89,7 +90,7 @@ func main() {
Name: "create",
Aliases: []string{"c"},
Usage: "create a service",
ArgsUsage: "[type: (o|l|b)] [id]",
ArgsUsage: "<type: oneshot|longrun|bundle> <id>",
Flags: []cli.Flag{
&cli.BoolFlag{Value: false, Name: "overwrite", Aliases: []string{"o"}, Usage: "Ignore existing files and directories"},
},
Expand All @@ -98,24 +99,17 @@ 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)
}

var id service.Id
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)
}

Expand Down

0 comments on commit 1e3b1d9

Please sign in to comment.