add --man flag for man page generation

add Taskfile.man.yml
include it in the main Taskfile

add man flag to Flags section in README
This commit is contained in:
2026-04-25 16:21:40 +01:00
parent b50f139366
commit 705190af26
8 changed files with 90 additions and 11 deletions

27
.gitignore vendored
View File

@@ -1,21 +1,40 @@
# Generated by ignr: github.com/onyx-and-iris/ignr
## Go ##
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
# Code coverage profiles and other test artifacts
*.out
coverage.*
*.coverprofile
profile.cov
# Dependency directories (remove the comment below to include it)
# vendor/
# Added by goreleaser init:
dist/
# Go workspace file
go.work
go.work.sum
# env file
.env
.envrc
# Editor/IDE
# .idea/
# .vscode/
# End of ignr
vbantxt.1

View File

@@ -11,7 +11,13 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
- [x]
# [0.6.0] - 2025-02-14
# [0.7.0] - 2026-04-25
### Added
- --man flag for man page generation.
# [0.6.0] - 2026-02-14
### Added

View File

@@ -98,6 +98,7 @@ FLAGS
-C, --config STRING Path to the configuration file (default: $XDG_CONFIG_HOME/vbantxt/config.toml)
-l, --loglevel STRING Log level (debug, info, warn, error, fatal, panic) (default: warn)
-v, --version Show version information
-m, --man Print man page and exit
```
Pass --host, --port and --streamname as flags on the root command, for example:

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

@@ -1,5 +1,8 @@
version: '3'
includes:
man: Taskfile.man.yml
vars:
PROGRAM: vbantxt
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
@@ -19,14 +22,14 @@ tasks:
build:
desc: 'Build the vbantxt project'
deps: [vet]
deps: [ vet ]
cmds:
- task: build-windows
- task: build-linux
- task: build-macos
vet:
desc: Vet the code
deps: [fmt]
deps: [ fmt ]
cmds:
- go vet ./...
@@ -38,19 +41,22 @@ tasks:
build-windows:
desc: Build the vbantxt project for Windows
cmds:
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}/
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X
main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}/
internal: true
build-linux:
desc: Build the vbantxt project for Linux
cmds:
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}/
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X
main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}/
internal: true
build-macos:
desc: Build the vbantxt project for macOS
cmds:
- GOOS=darwin GOARCH=amd64 go build -o {{.MACOS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}/
- GOOS=darwin GOARCH=amd64 go build -o {{.MACOS}} -ldflags="-X
main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}/
internal: true
test:

View File

@@ -10,7 +10,10 @@ import (
"strings"
"time"
mff "github.com/StevenACoffman/mango-ff"
"github.com/charmbracelet/log"
"github.com/muesli/mango"
"github.com/muesli/roff"
"github.com/peterbourgon/ff/v4"
"github.com/peterbourgon/ff/v4/ffhelp"
"github.com/peterbourgon/ff/v4/fftoml"
@@ -44,6 +47,7 @@ type Flags struct {
ConfigPath string // Path to the configuration file
Loglevel string // Log level
Version bool // Version flag
Man bool // Print the man page to stdout and exit
}
func (f *Flags) String() string {
@@ -118,6 +122,7 @@ func run() (func(), error) {
"Log level (debug, info, warn, error, fatal, panic)",
)
fs.BoolVar(&flags.Version, 'v', "version", "Show version information")
fs.BoolVar(&flags.Man, 'm', "man", "Print man page and exit")
err = ff.Parse(fs, os.Args[1:],
ff.WithEnvVarPrefix("VBANTXT"),
@@ -138,6 +143,22 @@ func run() (func(), error) {
return nil, nil
}
if flags.Man {
manPage := mango.NewManPage(
1,
"vbantxt",
"A command-line tool for sending text requests over VBAN",
)
if err := fs.WalkFlags(mff.FFlagVisitor(manPage)); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println(manPage.Build(roff.NewDocument()))
return nil, nil
}
level, err := log.ParseLevel(flags.Loglevel)
if err != nil {
return nil, fmt.Errorf("invalid log level %q", flags.Loglevel)

3
go.mod
View File

@@ -3,7 +3,10 @@ module github.com/onyx-and-iris/vbantxt
go 1.25.0
require (
github.com/StevenACoffman/mango-ff v0.0.0-20260411205343-7f039223efef
github.com/charmbracelet/log v1.0.0
github.com/muesli/mango v0.2.0
github.com/muesli/roff v0.1.0
github.com/peterbourgon/ff/v4 v4.0.0-beta.1
github.com/stretchr/testify v1.11.1
)

6
go.sum
View File

@@ -1,3 +1,5 @@
github.com/StevenACoffman/mango-ff v0.0.0-20260411205343-7f039223efef h1:dsNBocAa6MKaCZSZMDWwiFpjZzI7G24lGV/0t+s9SPY=
github.com/StevenACoffman/mango-ff v0.0.0-20260411205343-7f039223efef/go.mod h1:tvurZfjDXWtWGzD25r9esOSp729MCY96/rtchu+Jx30=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
@@ -33,6 +35,10 @@ github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLG
github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/muesli/mango v0.2.0 h1:iNNc0c5VLQ6fsMgAqGQofByNUBH2Q2nEbD6TaI+5yyQ=
github.com/muesli/mango v0.2.0/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/pelletier/go-toml/v2 v2.3.0 h1:k59bC/lIZREW0/iVaQR8nDHxVq8OVlIzYCOJf421CaM=