Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dazz committed Jan 5, 2024
1 parent ca6fa57 commit 3b97c48
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/s6-cli
/coverage.out
/s6-cli*
29 changes: 20 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
BINARY_NAME=s6-cli
S6_PATH := ./examples/s6-overlay/s6-rc.d
ARGS := -p $(S6_PATH)

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




# ==================================================================================== #
# QUALITY CONTROL
# ==================================================================================== #
Expand All @@ -31,10 +29,6 @@ audit:
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
go test -race -buildvcs -vet=off ./...

coverage:
@go test -coverprofile=coverage.out -v ./...
@go tool cover -html=coverage.out

# ==================================================================================== #
# DEVELOPMENT
# ==================================================================================== #
Expand All @@ -43,11 +37,22 @@ coverage:
no-dirty:
git diff --exit-code

.PHONY: dep
dep:
@go mod download

## build: build binary file
.PHONY: build
build:
@go build -o s6-cli -v ./cmd/s6cli
@GOARCH=amd64 GOOS=linux go build -o ${BINARY_NAME} -v ./cmd/s6cli

## clean: clean binary file
.PHONY: clean
clean:
@go clean
@rm -f ${BINARY_NAME}

## run: run binary file with good args
.PHONY: run
run:
@go run ./cmd/s6cli $(ARGS)
Expand All @@ -57,6 +62,12 @@ run:
test:
@go test -v ./...

## test-coverage: run all tests with coverage
.PHONY: test-coverage
test-coverage:
@go test -coverprofile=coverage.out -v ./...
@go tool cover -html=coverage.out

## nix: build binary file with nix
.PHONY: nix
nix:
Expand All @@ -66,7 +77,7 @@ nix:
# RUN COMMANDS OF CLI WITH DEFAULT ARGS
# ==================================================================================== #

## lint: lint s6-overlay folders and files
## lint: lint s6-overlay directories and files
.PHONY: lint
lint:
@go run ./cmd/s6cli $(ARGS) lint
Expand Down
124 changes: 117 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,119 @@
# s6-cli: A cli for s6-overlay
This cli tool can be used to help you setup your projects s6-overlay files and directories
# s6-cli: CLI for s6-overlay
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.

## s6-overlay
> 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.
To know more about s6-overlay visit [github.com/just-containers/s6-overlay](https://github.com/just-containers/s6-overlay).


## Setup

```bash
git clone [email protected]:dazz/s6-cli.git
cd s6-cli
make help
```

There is a Makefile that you can use to execute helpful commands. Following is a small list for some more important targets.
Run `make` or `make help` to see all possible targets.

## Build
There are a few options here how you can install the executable on the target system.

### Go
Builds the executable and places it in the current directory
```bash
make build
```

### Nix shell
If you have nix-shell you can run the following command to get a shell with the cli installed
```bash
make nix
```

### Docker
Creates a docker image with the cli installed
```bash
make docker
```

### In Dockerfile
If you want to use the cli in a Dockerfile you can copy it from the docker image
```dockerfile
COPY --from=hakindazz/s6-cli:latest /app/s6-cli /usr/local/bin/s6-cli
```

## Usage

There is a help command that you can use to get more info about the commands in the cli. Run it with
```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.
Default is set to `/etc/s6-overlay/s6-rc.d`

### Create
There are three types of services that can be created: Oneshot, Longrun and Background.
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}
```

### Remove
If the service is not needed anymore it can be removed with the following command.

```bash
./s6-cli remove {service}
```

### Lint

```bash
./s6-cli lint
```



### Mermaid
This command will generate a mermaid graph of the services.

```bash
./s6-cli mermaid > mermaid.md
```

Or pipe it directly to a markdown file
```bash
./s6-cli mermaid > mermaid.md
```

The output will look something like this:
```bash
```mermaid
graph TD;
user --> prepare-directory
user --> nginx
nginx --> php-fpm
php-fpm --> create-directories
```

which will be rendered to this:

```mermaid
graph TD;
user --> prepare-directory
user --> nginx
nginx --> php-fpm
php-fpm --> create-directories
```


## todo
* [ ] write tests with https://github.com/stretchr/testify
* [ ] find pattern for testcase names
* [ ] add `s6-cli update` command
* [ ] add `s6-cli init` command
* [ ] style output with color https://github.com/charmbracelet/glamour
* 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
2 changes: 1 addition & 1 deletion cmd/s6cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
rootPath := "/etc/s6-overlay/s6-rc.d"
app := &cli.App{
Name: "s6-cli",
Version: "0.0.1",
Version: "0.0.2",
Compiled: time.Now(),
Authors: []*cli.Author{
{
Expand Down

0 comments on commit 3b97c48

Please sign in to comment.