Skip to content

Commit

Permalink
feat #202: Added CLI to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
F1bonacc1 committed Aug 9, 2024
1 parent 9daea44 commit 7e95cfe
Show file tree
Hide file tree
Showing 29 changed files with 958 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ NUMVER = $(shell echo ${VERSION} | cut -d"v" -f 2)
PKG = github.com/f1bonacc1/${NAME}
SHELL := /bin/bash
PROJ_NAME := Process Compose
DOCS_DIR := www/docs/cli
LD_FLAGS := -ldflags="-X ${PKG}/src/config.Version=${VERSION} \
-X ${PKG}/src/config.CheckForUpdates=true \
-X ${PKG}/src/config.Commit=${GIT_REV} \
Expand All @@ -20,7 +21,7 @@ ifeq ($(OS),Windows_NT)
RM = cmd /C del /Q /F
endif

.PHONY: test run testrace
.PHONY: test run testrace docs

buildrun: build run

Expand Down Expand Up @@ -81,3 +82,9 @@ snapshot:
github-workflows:
act -W ./.github/workflows/go.yml -j build
act -W ./.github/workflows/nix.yml -j build

docs:
./bin/process-compose docs ${DOCS_DIR}
for f in ${DOCS_DIR}/*.md ; do sed -i 's/${USER}/<user>/g' $$f ; done
for f in ${DOCS_DIR}/*.md ; do sed -i 's/process-compose-[0-9]\+.sock/process-compose-<pid>.sock/g' $$f ; done

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ require (
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
Expand Down Expand Up @@ -63,6 +64,7 @@ require (
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJ
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
Expand Down Expand Up @@ -149,6 +150,7 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64=
Expand Down
27 changes: 27 additions & 0 deletions src/cmd/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/spf13/cobra/doc"

"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)

// docsCmd represents the docs command
var docsCmd = &cobra.Command{
Use: "docs [OUTPUT_PATH]",
Short: "Generate Process Compose markdown documentation",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
outPath := args[0]
err := doc.GenMarkdownTree(rootCmd, outPath)
if err != nil {
log.Fatal().Err(err).Msg("Failed to generate docs")
}
},
Hidden: true,
}

func init() {
rootCmd.AddCommand(docsCmd)
}
45 changes: 45 additions & 0 deletions www/docs/cli/process-compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## process-compose

Processes scheduler and orchestrator

```
process-compose [flags]
```

### Options

```
-f, --config stringArray path to config files to load (env: PC_CONFIG_FILES)
--disable-dotenv disable .env file loading (env: PC_DISABLE_DOTENV=1)
-h, --help help for process-compose
-d, --hide-disabled hide disabled processes
--keep-tui keep TUI running even after all processes exit
-L, --log-file string Specify the log file path (env: PC_LOG_FILE) (default "/tmp/process-compose-<user>.log")
-n, --namespace stringArray run only specified namespaces (default all)
--no-server disable HTTP server (env: PC_NO_SERVER)
--ordered-shutdown shut down processes in reverse dependency order
-p, --port int port number (env: PC_PORT_NUM) (default 8080)
--read-only enable read-only mode (env: PC_READ_ONLY)
-r, --ref-rate duration TUI refresh rate in seconds or as a Go duration string (e.g. 1s) (default 1)
-R, --reverse sort in reverse order
-S, --sort string sort column name. legal values (case insensitive): [AGE, EXIT, HEALTH, MEM, NAME, NAMESPACE, PID, RESTARTS, STATUS] (default "NAME")
--theme string select process compose theme (default "Default")
-t, --tui enable TUI (disable with -t=false) (env: PC_DISABLE_TUI) (default true)
--tui-fs enable TUI full screen (env: PC_TUI_FULL_SCREEN=1)
-u, --unix-socket string path to unix socket (env: PC_SOCKET_PATH) (default "/tmp/process-compose-<pid>.sock")
-U, --use-uds use unix domain sockets instead of tcp
```

### SEE ALSO

* [process-compose attach](process-compose_attach.md) - Attach the Process Compose TUI Remotely to a Running Process Compose Server
* [process-compose completion](process-compose_completion.md) - Generate the autocompletion script for the specified shell
* [process-compose down](process-compose_down.md) - Stops all the running processes and terminates the Process Compose
* [process-compose info](process-compose_info.md) - Print configuration info
* [process-compose process](process-compose_process.md) - Execute operations on the available processes
* [process-compose project](process-compose_project.md) - Execute operations on a running Process Compose project
* [process-compose run](process-compose_run.md) - Run PROCESS in the foreground, and its dependencies in the background
* [process-compose up](process-compose_up.md) - Run process compose project
* [process-compose version](process-compose_version.md) - Print version and build info

###### Auto generated by spf13/cobra on 27-Jul-2024
38 changes: 38 additions & 0 deletions www/docs/cli/process-compose_attach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## process-compose attach

Attach the Process Compose TUI Remotely to a Running Process Compose Server

```
process-compose attach [flags]
```

### Options

```
-a, --address string address of the target process compose server (default "localhost")
-h, --help help for attach
-l, --log-length int log length to display in TUI (default 1000)
-r, --ref-rate duration TUI refresh rate in seconds or as a Go duration string (e.g. 1s) (default 1)
-R, --reverse sort in reverse order
-S, --sort string sort column name. legal values (case insensitive): [AGE, EXIT, HEALTH, MEM, NAME, NAMESPACE, PID, RESTARTS, STATUS] (default "NAME")
--theme string select process compose theme (default "Default")
```

### Options inherited from parent commands

```
--keep-tui keep TUI running even after all processes exit
-L, --log-file string Specify the log file path (env: PC_LOG_FILE) (default "/tmp/process-compose-<user>.log")
--no-server disable HTTP server (env: PC_NO_SERVER)
--ordered-shutdown shut down processes in reverse dependency order
-p, --port int port number (env: PC_PORT_NUM) (default 8080)
--read-only enable read-only mode (env: PC_READ_ONLY)
-u, --unix-socket string path to unix socket (env: PC_SOCKET_PATH) (default "/tmp/process-compose-<pid>.sock")
-U, --use-uds use unix domain sockets instead of tcp
```

### SEE ALSO

* [process-compose](process-compose.md) - Processes scheduler and orchestrator

###### Auto generated by spf13/cobra on 27-Jul-2024
38 changes: 38 additions & 0 deletions www/docs/cli/process-compose_completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## process-compose completion

Generate the autocompletion script for the specified shell

### Synopsis

Generate the autocompletion script for process-compose for the specified shell.
See each sub-command's help for details on how to use the generated script.


### Options

```
-h, --help help for completion
```

### Options inherited from parent commands

```
--keep-tui keep TUI running even after all processes exit
-L, --log-file string Specify the log file path (env: PC_LOG_FILE) (default "/tmp/process-compose-<user>.log")
--no-server disable HTTP server (env: PC_NO_SERVER)
--ordered-shutdown shut down processes in reverse dependency order
-p, --port int port number (env: PC_PORT_NUM) (default 8080)
--read-only enable read-only mode (env: PC_READ_ONLY)
-u, --unix-socket string path to unix socket (env: PC_SOCKET_PATH) (default "/tmp/process-compose-<pid>.sock")
-U, --use-uds use unix domain sockets instead of tcp
```

### SEE ALSO

* [process-compose](process-compose.md) - Processes scheduler and orchestrator
* [process-compose completion bash](process-compose_completion_bash.md) - Generate the autocompletion script for bash
* [process-compose completion fish](process-compose_completion_fish.md) - Generate the autocompletion script for fish
* [process-compose completion powershell](process-compose_completion_powershell.md) - Generate the autocompletion script for powershell
* [process-compose completion zsh](process-compose_completion_zsh.md) - Generate the autocompletion script for zsh

###### Auto generated by spf13/cobra on 27-Jul-2024
57 changes: 57 additions & 0 deletions www/docs/cli/process-compose_completion_bash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## process-compose completion bash

Generate the autocompletion script for bash

### Synopsis

Generate the autocompletion script for the bash shell.

This script depends on the 'bash-completion' package.
If it is not installed already, you can install it via your OS's package manager.

To load completions in your current shell session:

source <(process-compose completion bash)

To load completions for every new session, execute once:

#### Linux:

process-compose completion bash > /etc/bash_completion.d/process-compose

#### macOS:

process-compose completion bash > $(brew --prefix)/etc/bash_completion.d/process-compose

You will need to start a new shell for this setup to take effect.


```
process-compose completion bash
```

### Options

```
-h, --help help for bash
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--keep-tui keep TUI running even after all processes exit
-L, --log-file string Specify the log file path (env: PC_LOG_FILE) (default "/tmp/process-compose-<user>.log")
--no-server disable HTTP server (env: PC_NO_SERVER)
--ordered-shutdown shut down processes in reverse dependency order
-p, --port int port number (env: PC_PORT_NUM) (default 8080)
--read-only enable read-only mode (env: PC_READ_ONLY)
-u, --unix-socket string path to unix socket (env: PC_SOCKET_PATH) (default "/tmp/process-compose-<pid>.sock")
-U, --use-uds use unix domain sockets instead of tcp
```

### SEE ALSO

* [process-compose completion](process-compose_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 27-Jul-2024
48 changes: 48 additions & 0 deletions www/docs/cli/process-compose_completion_fish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## process-compose completion fish

Generate the autocompletion script for fish

### Synopsis

Generate the autocompletion script for the fish shell.

To load completions in your current shell session:

process-compose completion fish | source

To load completions for every new session, execute once:

process-compose completion fish > ~/.config/fish/completions/process-compose.fish

You will need to start a new shell for this setup to take effect.


```
process-compose completion fish [flags]
```

### Options

```
-h, --help help for fish
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--keep-tui keep TUI running even after all processes exit
-L, --log-file string Specify the log file path (env: PC_LOG_FILE) (default "/tmp/process-compose-<user>.log")
--no-server disable HTTP server (env: PC_NO_SERVER)
--ordered-shutdown shut down processes in reverse dependency order
-p, --port int port number (env: PC_PORT_NUM) (default 8080)
--read-only enable read-only mode (env: PC_READ_ONLY)
-u, --unix-socket string path to unix socket (env: PC_SOCKET_PATH) (default "/tmp/process-compose-<pid>.sock")
-U, --use-uds use unix domain sockets instead of tcp
```

### SEE ALSO

* [process-compose completion](process-compose_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 27-Jul-2024
45 changes: 45 additions & 0 deletions www/docs/cli/process-compose_completion_powershell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## process-compose completion powershell

Generate the autocompletion script for powershell

### Synopsis

Generate the autocompletion script for powershell.

To load completions in your current shell session:

process-compose completion powershell | Out-String | Invoke-Expression

To load completions for every new session, add the output of the above command
to your powershell profile.


```
process-compose completion powershell [flags]
```

### Options

```
-h, --help help for powershell
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--keep-tui keep TUI running even after all processes exit
-L, --log-file string Specify the log file path (env: PC_LOG_FILE) (default "/tmp/process-compose-<user>.log")
--no-server disable HTTP server (env: PC_NO_SERVER)
--ordered-shutdown shut down processes in reverse dependency order
-p, --port int port number (env: PC_PORT_NUM) (default 8080)
--read-only enable read-only mode (env: PC_READ_ONLY)
-u, --unix-socket string path to unix socket (env: PC_SOCKET_PATH) (default "/tmp/process-compose-<pid>.sock")
-U, --use-uds use unix domain sockets instead of tcp
```

### SEE ALSO

* [process-compose completion](process-compose_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 27-Jul-2024
Loading

0 comments on commit 7e95cfe

Please sign in to comment.