Skip to content

Commit 3b97c48

Browse files
committed
improve readme
1 parent ca6fa57 commit 3b97c48

File tree

4 files changed

+139
-17
lines changed

4 files changed

+139
-17
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/s6-cli
22
/coverage.out
3+
/s6-cli*

Makefile

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
BINARY_NAME=s6-cli
12
S6_PATH := ./examples/s6-overlay/s6-rc.d
23
ARGS := -p $(S6_PATH)
34

@@ -9,9 +10,6 @@ help:
910
@echo 'Usage:'
1011
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
1112

12-
13-
14-
1513
# ==================================================================================== #
1614
# QUALITY CONTROL
1715
# ==================================================================================== #
@@ -31,10 +29,6 @@ audit:
3129
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
3230
go test -race -buildvcs -vet=off ./...
3331

34-
coverage:
35-
@go test -coverprofile=coverage.out -v ./...
36-
@go tool cover -html=coverage.out
37-
3832
# ==================================================================================== #
3933
# DEVELOPMENT
4034
# ==================================================================================== #
@@ -43,11 +37,22 @@ coverage:
4337
no-dirty:
4438
git diff --exit-code
4539

40+
.PHONY: dep
41+
dep:
42+
@go mod download
43+
4644
## build: build binary file
4745
.PHONY: build
4846
build:
49-
@go build -o s6-cli -v ./cmd/s6cli
47+
@GOARCH=amd64 GOOS=linux go build -o ${BINARY_NAME} -v ./cmd/s6cli
48+
49+
## clean: clean binary file
50+
.PHONY: clean
51+
clean:
52+
@go clean
53+
@rm -f ${BINARY_NAME}
5054

55+
## run: run binary file with good args
5156
.PHONY: run
5257
run:
5358
@go run ./cmd/s6cli $(ARGS)
@@ -57,6 +62,12 @@ run:
5762
test:
5863
@go test -v ./...
5964

65+
## test-coverage: run all tests with coverage
66+
.PHONY: test-coverage
67+
test-coverage:
68+
@go test -coverprofile=coverage.out -v ./...
69+
@go tool cover -html=coverage.out
70+
6071
## nix: build binary file with nix
6172
.PHONY: nix
6273
nix:
@@ -66,7 +77,7 @@ nix:
6677
# RUN COMMANDS OF CLI WITH DEFAULT ARGS
6778
# ==================================================================================== #
6879

69-
## lint: lint s6-overlay folders and files
80+
## lint: lint s6-overlay directories and files
7081
.PHONY: lint
7182
lint:
7283
@go run ./cmd/s6cli $(ARGS) lint

README.md

+117-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,119 @@
1-
# s6-cli: A cli for s6-overlay
2-
This cli tool can be used to help you setup your projects s6-overlay files and directories
1+
# s6-cli: CLI for s6-overlay
2+
This cli tool can be used to help you setup your projects s6-overlay files and directories. It can also be used to create, remove and lint services.
3+
4+
## s6-overlay
5+
> s6-overlay is an easy-to-install (just extract a tarball or two!) set of scripts and utilities allowing you to use existing Docker images while using s6 as a pid 1 for your container and process supervisor for your services.
6+
To know more about s6-overlay visit [github.com/just-containers/s6-overlay](https://github.com/just-containers/s6-overlay).
7+
8+
9+
## Setup
10+
11+
```bash
12+
git clone [email protected]:dazz/s6-cli.git
13+
cd s6-cli
14+
make help
15+
```
16+
17+
There is a Makefile that you can use to execute helpful commands. Following is a small list for some more important targets.
18+
Run `make` or `make help` to see all possible targets.
19+
20+
## Build
21+
There are a few options here how you can install the executable on the target system.
22+
23+
### Go
24+
Builds the executable and places it in the current directory
25+
```bash
26+
make build
27+
```
28+
29+
### Nix shell
30+
If you have nix-shell you can run the following command to get a shell with the cli installed
31+
```bash
32+
make nix
33+
```
34+
35+
### Docker
36+
Creates a docker image with the cli installed
37+
```bash
38+
make docker
39+
```
40+
41+
### In Dockerfile
42+
If you want to use the cli in a Dockerfile you can copy it from the docker image
43+
```dockerfile
44+
COPY --from=hakindazz/s6-cli:latest /app/s6-cli /usr/local/bin/s6-cli
45+
```
46+
47+
## Usage
48+
49+
There is a help command that you can use to get more info about the commands in the cli. Run it with
50+
```bash
51+
./s6-cli help
52+
```
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.
55+
Default is set to `/etc/s6-overlay/s6-rc.d`
56+
57+
### Create
58+
There are three types of services that can be created: Oneshot, Longrun and Background.
59+
Read more about them [here](https://skarnet.org/software/s6-rc/s6-rc-compile.html)
60+
61+
```bash
62+
./s6-cli --rootPath {path} create {o|l|b} {service}
63+
```
64+
65+
### Remove
66+
If the service is not needed anymore it can be removed with the following command.
67+
68+
```bash
69+
./s6-cli remove {service}
70+
```
71+
72+
### Lint
73+
74+
```bash
75+
./s6-cli lint
76+
```
77+
78+
79+
80+
### Mermaid
81+
This command will generate a mermaid graph of the services.
82+
83+
```bash
84+
./s6-cli mermaid > mermaid.md
85+
```
86+
87+
Or pipe it directly to a markdown file
88+
```bash
89+
./s6-cli mermaid > mermaid.md
90+
```
91+
92+
The output will look something like this:
93+
```bash
94+
```mermaid
95+
graph TD;
96+
user --> prepare-directory
97+
user --> nginx
98+
nginx --> php-fpm
99+
php-fpm --> create-directories
100+
```
101+
102+
which will be rendered to this:
103+
104+
```mermaid
105+
graph TD;
106+
user --> prepare-directory
107+
user --> nginx
108+
nginx --> php-fpm
109+
php-fpm --> create-directories
110+
```
111+
3112

4113
## todo
5-
* [ ] write tests with https://github.com/stretchr/testify
6-
* [ ] find pattern for testcase names
7-
* [ ] add `s6-cli update` command
8-
* [ ] add `s6-cli init` command
9-
* [ ] style output with color https://github.com/charmbracelet/glamour
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func main() {
1919
rootPath := "/etc/s6-overlay/s6-rc.d"
2020
app := &cli.App{
2121
Name: "s6-cli",
22-
Version: "0.0.1",
22+
Version: "0.0.2",
2323
Compiled: time.Now(),
2424
Authors: []*cli.Author{
2525
{

0 commit comments

Comments
 (0)