4 Commits

Author SHA1 Message Date
e0c15f3ba5 remove duplicate taskfiles 2026-03-20 20:06:37 +00:00
1f4b261fc4 remove duplicate taskfile 2026-03-20 19:53:55 +00:00
739ce44288 add generate-readme task
add generate_help.go

update pre-commit hook
2026-03-20 19:49:36 +00:00
1b9cc1f66a add man command to both CLIs
add man Taskfiles
2026-03-20 19:20:29 +00:00
14 changed files with 94 additions and 34 deletions

6
.gitignore vendored
View File

@@ -38,4 +38,8 @@ go.work.sum
# End of ignr
update_readme.py
# Man pages
xair-cli.1
x32-cli.1
update_readme.py

View File

@@ -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

View File

@@ -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

View File

@@ -1,22 +0,0 @@
version: '3'
vars:
WINDOWS: '{{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe'
LINUX: '{{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64'
MACOS: '{{.BIN_DIR}}/{{.PROGRAM}}_darwin_amd64'
tasks:
windows-amd64:
desc: Build the xair-cli project for Windows
cmds:
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}
linux-amd64:
desc: Build the xair-cli project for Linux
cmds:
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}
darwin-amd64:
desc: Build the xair-cli project for macOS
cmds:
- GOOS=darwin GOARCH=amd64 go build -o {{.MACOS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}

View File

@@ -7,16 +7,16 @@ vars:
tasks:
windows-amd64:
desc: Build the x32-cli project for Windows
desc: Build the project for Windows
cmds:
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}
linux-amd64:
desc: Build the x32-cli project for Linux
desc: Build the project for Linux
cmds:
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}
darwin-amd64:
desc: Build the x32-cli project for macOS
desc: Build the project for macOS
cmds:
- GOOS=darwin GOARCH=amd64 go build -o {{.MACOS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}

17
Taskfile.man.yml Normal file
View File

@@ -0,0 +1,17 @@
version: '3'
tasks:
default:
desc: View man page
cmds:
- task: view
view:
desc: View man page
cmds:
- go run ./cmd/{{.PROGRAM}} --man | man -l -
generate:
desc: Generate man page
cmds:
- go run ./cmd/{{.PROGRAM}} --man > {{.PROGRAM}}.1

View File

@@ -2,15 +2,23 @@ version: '3'
includes:
build-xair:
taskfile: ./Taskfile.build-xair.yml
taskfile: ./Taskfile.build.yml
internal: true
vars:
PROGRAM: xair-cli
build-x32:
taskfile: ./Taskfile.build-x32.yml
taskfile: ./Taskfile.build.yml
internal: true
vars:
PROGRAM: x32-cli
man-xair:
taskfile: ./Taskfile.man.yml
vars:
PROGRAM: xair-cli
man-x32:
taskfile: ./Taskfile.man.yml
vars:
PROGRAM: x32-cli
vars:
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
@@ -54,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

View File

@@ -9,6 +9,7 @@ import (
"time"
"github.com/alecthomas/kong"
mangokong "github.com/alecthomas/mango-kong"
"github.com/charmbracelet/log"
kongcompletion "github.com/jotaen/kong-completion"
@@ -50,7 +51,8 @@ type Config struct {
type CLI struct {
Config `embed:"" prefix:"" help:"The configuration for the CLI."`
Version VersionFlag `help:"Print x32-cli version information and quit" name:"version" short:"v"`
Man mangokong.ManFlag `help:"Print man page."`
Version VersionFlag `help:"Print x32-cli version information and quit" name:"version" short:"v"`
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:""`
Info InfoCmd `help:"Print mixer information." cmd:""`

View File

@@ -9,6 +9,7 @@ import (
"time"
"github.com/alecthomas/kong"
mangokong "github.com/alecthomas/mango-kong"
"github.com/charmbracelet/log"
kongcompletion "github.com/jotaen/kong-completion"
@@ -50,7 +51,8 @@ type Config struct {
type CLI struct {
Config `embed:"" prefix:"" help:"The configuration for the CLI."`
Version VersionFlag `help:"Print xair-cli version information and quit" name:"version" short:"v"`
Man mangokong.ManFlag `help:"Print man page."`
Version VersionFlag `help:"Print xair-cli version information and quit" name:"version" short:"v"`
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:""`
Info InfoCmd `help:"Print mixer information." cmd:""`

3
go.mod
View File

@@ -4,6 +4,7 @@ go 1.25.0
require (
github.com/alecthomas/kong v1.14.0
github.com/alecthomas/mango-kong v0.1.0
github.com/charmbracelet/log v1.0.0
github.com/hypebeast/go-osc v0.0.0-20220308234300-cec5a8a1e5f5
github.com/jotaen/kong-completion v0.0.12
@@ -24,6 +25,8 @@ require (
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.21 // indirect
github.com/muesli/mango v0.1.1-0.20220205060214-77e2058169ab // indirect
github.com/muesli/roff v0.1.0 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rivo/uniseg v0.4.7 // indirect

6
go.sum
View File

@@ -2,6 +2,8 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8v
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/kong v1.14.0 h1:gFgEUZWu2ZmZ+UhyZ1bDhuutbKN1nTtJTwh19Wsn21s=
github.com/alecthomas/kong v1.14.0/go.mod h1:wrlbXem1CWqUV5Vbmss5ISYhsVPkBb1Yo7YKJghju2I=
github.com/alecthomas/mango-kong v0.1.0 h1:iFVfP1k1K4qpml3JUQmD5I8MCQYfIvsD9mRdrw7jJC4=
github.com/alecthomas/mango-kong v0.1.0/go.mod h1:t+TYVdsONUolf/BwVcm+15eqcdAj15h4Qe9MMFAwwT4=
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
@@ -47,6 +49,10 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.21 h1:jJKAZiQH+2mIinzCJIaIG9Be1+0NR+5sz/lYEEjdM8w=
github.com/mattn/go-runewidth v0.0.21/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/muesli/mango v0.1.1-0.20220205060214-77e2058169ab h1:m7QFONkzLK0fVXCjwX5tANcnj1yXxTnYQtnfJiY3tcA=
github.com/muesli/mango v0.1.1-0.20220205060214-77e2058169ab/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

31
tools/generate_help.go Normal file
View 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)
}
}

View File

@@ -9,6 +9,7 @@ Flags:
-P, --port=10023 The port of the X32 device ($X32_CLI_PORT).
-T, --timeout=100ms Timeout for OSC operations ($X32_CLI_TIMEOUT).
-L, --loglevel="warn" Log level for the CLI ($X32_CLI_LOGLEVEL).
--man Print man page.
-v, --version Print x32-cli version information and quit
Commands:
@@ -194,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.
```

View File

@@ -9,6 +9,7 @@ Flags:
-P, --port=10024 The port of the X-Air device ($XAIR_CLI_PORT).
-T, --timeout=100ms Timeout for OSC operations ($XAIR_CLI_TIMEOUT).
-L, --loglevel="warn" Log level for the CLI ($XAIR_CLI_LOGLEVEL).
--man Print man page.
-v, --version Print xair-cli version information and quit
Commands:
@@ -126,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.
```