mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-04-08 18:03:37 +00:00
add generate-readme task
add generate_help.go update pre-commit hook
This commit is contained in:
@@ -3,6 +3,6 @@ repos:
|
||||
hooks:
|
||||
- id: update-readme
|
||||
name: update-readme
|
||||
entry: python update_readme.py
|
||||
language: python
|
||||
entry: go generate ./tools
|
||||
language: system
|
||||
pass_filenames: false
|
||||
|
||||
@@ -60,8 +60,8 @@ export X32_CLI_LOGLEVEL=warn
|
||||
|
||||
For each command/subcommand in the tree there exists a `--help` flag, use it to print usage information.
|
||||
|
||||
- [xair-cli](./xair-help.md)
|
||||
- [x32-cli](./x32-help.md)
|
||||
- [xair-cli](./tools/xair-help.md)
|
||||
- [x32-cli](./tools/x32-help.md)
|
||||
|
||||
### Examples
|
||||
|
||||
|
||||
@@ -62,3 +62,8 @@ tasks:
|
||||
desc: Clean the build artifacts
|
||||
cmds:
|
||||
- '{{.SHELL}} rm -r {{.BIN_DIR}}'
|
||||
|
||||
update-readme:
|
||||
desc: Update the README.md file with the latest help output from the commands
|
||||
cmds:
|
||||
- go generate ./tools
|
||||
|
||||
31
tools/generate_help.go
Normal file
31
tools/generate_help.go
Normal file
@@ -0,0 +1,31 @@
|
||||
//go:generate go run generate_help.go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
clis := []struct {
|
||||
cmd string
|
||||
out string
|
||||
}{
|
||||
{"../cmd/xair-cli/", "xair-help.md"},
|
||||
{"../cmd/x32-cli/", "x32-help.md"},
|
||||
}
|
||||
|
||||
for _, cli := range clis {
|
||||
helpCmd := exec.Command("go", "run", cli.cmd, "--help")
|
||||
out, err := helpCmd.Output()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Wrap output in markdown console code block
|
||||
wrapped := append([]byte("```console\n"), out...)
|
||||
wrapped = append(wrapped, []byte("\n```\n")...)
|
||||
os.WriteFile(cli.out, wrapped, 0o644)
|
||||
}
|
||||
}
|
||||
@@ -195,4 +195,5 @@ DCA
|
||||
dca <index> name Get or set the name of the DCA group.
|
||||
|
||||
Run "x32-cli <command> --help" for more information on a command.
|
||||
|
||||
```
|
||||
@@ -127,4 +127,5 @@ DCA
|
||||
dca <index> name Get or set the name of the DCA group.
|
||||
|
||||
Run "xair-cli <command> --help" for more information on a command.
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user