Skip to content

Commit 1e3b1d9

Browse files
committed
update create arg
1 parent cc5e2ce commit 1e3b1d9

2 files changed

Lines changed: 17 additions & 27 deletions

File tree

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ Creates a docker image with the cli installed
3838
make docker
3939
```
4040

41+
or if you pulled the image from dockerhub
42+
```bash
43+
docker run -it --rm -v ./examples/s6-overlay:/etc/s6-overlay hakindazz/s6-cli:latest
44+
```
45+
46+
4147
### In Dockerfile
4248
If you want to use the cli in a Dockerfile you can copy it from the docker image
4349
```dockerfile
@@ -50,16 +56,16 @@ There is a help command that you can use to get more info about the commands in
5056
```bash
5157
./s6-cli help
5258
```
53-
### The option `--rootPath {path}, -p {path}`
54-
All commands need the `rootPath` to be specified. It must point to the directory where services will be defined.
59+
### The option `--root-path {path}, -p {path}`
60+
All commands need the `root-path` to be specified. It must point to the directory where services will be defined.
5561
Default is set to `/etc/s6-overlay/s6-rc.d`
5662

5763
### Create
5864
There are three types of services that can be created: Oneshot, Longrun and Bundle.
5965
Read more about them [here](https://skarnet.org/software/s6-rc/s6-rc-compile.html)
6066

6167
```bash
62-
./s6-cli --rootPath {path} create {o|l|b} {service}
68+
./s6-cli --root-path {path} create {oneshot|longrun|bundle} {service}
6369
```
6470

6571
### Remove
@@ -76,7 +82,6 @@ If the service is not needed anymore it can be removed with the following comman
7682
```
7783

7884

79-
8085
### Mermaid
8186
This command will generate a mermaid graph of the services.
8287

@@ -108,12 +113,3 @@ graph TD;
108113
nginx --> php-fpm
109114
php-fpm --> create-directories
110115
```
111-
112-
113-
## todo
114-
* create dependencies between services
115-
* add `s6-cli update` command
116-
* add `s6-cli init` command
117-
* add `s6-cli ci` command
118-
* style output with color https://github.com/charmbracelet/glamour
119-
* tui with https://github.com/charmbracelet/bubbletea

cmd/s6cli/main.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func main() {
2020
rootPath := "/etc/s6-overlay/s6-rc.d"
2121
app := &cli.App{
2222
Name: "s6-cli",
23-
Version: "0.0.2",
23+
Version: "v0.2.0",
2424
Compiled: time.Now(),
2525
Authors: []*cli.Author{
2626
{
@@ -58,7 +58,8 @@ func main() {
5858
}
5959
if execute != "" {
6060
fmt.Println("s6-cli: lint found issues with services in " + rootPath)
61-
return errors.New(execute)
61+
fmt.Println(execute)
62+
return nil
6263
}
6364
fmt.Println("s6-cli: lint found no issues")
6465
return nil
@@ -89,7 +90,7 @@ func main() {
8990
Name: "create",
9091
Aliases: []string{"c"},
9192
Usage: "create a service",
92-
ArgsUsage: "[type: (o|l|b)] [id]",
93+
ArgsUsage: "<type: oneshot|longrun|bundle> <id>",
9394
Flags: []cli.Flag{
9495
&cli.BoolFlag{Value: false, Name: "overwrite", Aliases: []string{"o"}, Usage: "Ignore existing files and directories"},
9596
},
@@ -98,24 +99,17 @@ func main() {
9899
rootPath = cCtx.String("root-path")
99100
}
100101

101-
var serviceType service.Type
102-
switch t := cCtx.Args().Get(0); t {
103-
case "o":
104-
serviceType = service.TypeOneshot
105-
case "l":
106-
serviceType = service.TypeLongrun
107-
case "b":
108-
serviceType = service.TypeBundle
109-
default:
110-
fmt.Print("Arg type must not be empty and one of 'o', 'l' or 'b'\n")
102+
var serviceType = service.Type(cCtx.Args().Get(0))
103+
if service.ValidType(serviceType) == false {
104+
fmt.Println("Argument type be one of 'oneshot', 'longrun' or 'bundle'")
111105
os.Exit(1)
112106
}
113107

114108
var id service.Id
115109
if idArg := cCtx.Args().Get(1); idArg != "" {
116110
id = service.Id(idArg)
117111
} else {
118-
fmt.Println("Arg idArg must not be empty")
112+
fmt.Println("Argument id must not be empty")
119113
os.Exit(1)
120114
}
121115

0 commit comments

Comments
 (0)