diff --git a/.gitignore b/.gitignore index 3c69be4..21ca0b5 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,8 @@ go.work.sum # End of ignr -update_readme.py \ No newline at end of file +# Man pages +xair-cli.1 +x32-cli.1 + +update_readme.py diff --git a/Taskfile.man-x32.yml b/Taskfile.man-x32.yml new file mode 100644 index 0000000..a0c40b2 --- /dev/null +++ b/Taskfile.man-x32.yml @@ -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 diff --git a/Taskfile.man-xair.yml b/Taskfile.man-xair.yml new file mode 100644 index 0000000..a0c40b2 --- /dev/null +++ b/Taskfile.man-xair.yml @@ -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 diff --git a/Taskfile.yml b/Taskfile.yml index 3a82593..07fdece 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -11,6 +11,14 @@ includes: internal: true vars: PROGRAM: x32-cli + man-xair: + taskfile: ./Taskfile.man-xair.yml + vars: + PROGRAM: xair-cli + man-x32: + taskfile: ./Taskfile.man-x32.yml + vars: + PROGRAM: x32-cli vars: SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}' diff --git a/cmd/x32-cli/cli.go b/cmd/x32-cli/cli.go index 50bf9f0..4cc9f7b 100644 --- a/cmd/x32-cli/cli.go +++ b/cmd/x32-cli/cli.go @@ -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:""` diff --git a/cmd/xair-cli/cli.go b/cmd/xair-cli/cli.go index dcc6145..e807a7a 100644 --- a/cmd/xair-cli/cli.go +++ b/cmd/xair-cli/cli.go @@ -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:""` diff --git a/go.mod b/go.mod index c211d9c..004a440 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 30e0b8f..9e80d66 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/x32-help.md b/x32-help.md index 767979e..e065faa 100644 --- a/x32-help.md +++ b/x32-help.md @@ -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: diff --git a/xair-help.md b/xair-help.md index b3e85cf..523dc65 100644 --- a/xair-help.md +++ b/xair-help.md @@ -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: