mirror of
https://github.com/onyx-and-iris/vbantxt.git
synced 2026-04-29 20:33:32 +00:00
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:
27
.gitignore
vendored
27
.gitignore
vendored
@@ -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
|
# Binaries for programs and plugins
|
||||||
*.exe
|
*.exe
|
||||||
*.exe~
|
*.exe~
|
||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
bin/
|
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Code coverage profiles and other test artifacts
|
||||||
*.out
|
*.out
|
||||||
|
coverage.*
|
||||||
|
*.coverprofile
|
||||||
|
profile.cov
|
||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
|
|
||||||
# Added by goreleaser init:
|
# Go workspace file
|
||||||
dist/
|
go.work
|
||||||
|
go.work.sum
|
||||||
|
|
||||||
|
# env file
|
||||||
|
.env
|
||||||
.envrc
|
.envrc
|
||||||
|
|
||||||
|
# Editor/IDE
|
||||||
|
# .idea/
|
||||||
|
# .vscode/
|
||||||
|
|
||||||
|
# End of ignr
|
||||||
|
|
||||||
|
vbantxt.1
|
||||||
@@ -11,7 +11,13 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
|
|
||||||
- [x]
|
- [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
|
### Added
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ FLAGS
|
|||||||
-C, --config STRING Path to the configuration file (default: $XDG_CONFIG_HOME/vbantxt/config.toml)
|
-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)
|
-l, --loglevel STRING Log level (debug, info, warn, error, fatal, panic) (default: warn)
|
||||||
-v, --version Show version information
|
-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:
|
Pass --host, --port and --streamname as flags on the root command, for example:
|
||||||
|
|||||||
17
Taskfile.man.yml
Normal file
17
Taskfile.man.yml
Normal 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
|
||||||
12
Taskfile.yml
12
Taskfile.yml
@@ -1,5 +1,8 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
|
includes:
|
||||||
|
man: Taskfile.man.yml
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
PROGRAM: vbantxt
|
PROGRAM: vbantxt
|
||||||
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
|
||||||
@@ -38,19 +41,22 @@ tasks:
|
|||||||
build-windows:
|
build-windows:
|
||||||
desc: Build the vbantxt project for Windows
|
desc: Build the vbantxt project for Windows
|
||||||
cmds:
|
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
|
internal: true
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
desc: Build the vbantxt project for Linux
|
desc: Build the vbantxt project for Linux
|
||||||
cmds:
|
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
|
internal: true
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
desc: Build the vbantxt project for macOS
|
desc: Build the vbantxt project for macOS
|
||||||
cmds:
|
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
|
internal: true
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
mff "github.com/StevenACoffman/mango-ff"
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
|
"github.com/muesli/mango"
|
||||||
|
"github.com/muesli/roff"
|
||||||
"github.com/peterbourgon/ff/v4"
|
"github.com/peterbourgon/ff/v4"
|
||||||
"github.com/peterbourgon/ff/v4/ffhelp"
|
"github.com/peterbourgon/ff/v4/ffhelp"
|
||||||
"github.com/peterbourgon/ff/v4/fftoml"
|
"github.com/peterbourgon/ff/v4/fftoml"
|
||||||
@@ -44,6 +47,7 @@ type Flags struct {
|
|||||||
ConfigPath string // Path to the configuration file
|
ConfigPath string // Path to the configuration file
|
||||||
Loglevel string // Log level
|
Loglevel string // Log level
|
||||||
Version bool // Version flag
|
Version bool // Version flag
|
||||||
|
Man bool // Print the man page to stdout and exit
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Flags) String() string {
|
func (f *Flags) String() string {
|
||||||
@@ -118,6 +122,7 @@ func run() (func(), error) {
|
|||||||
"Log level (debug, info, warn, error, fatal, panic)",
|
"Log level (debug, info, warn, error, fatal, panic)",
|
||||||
)
|
)
|
||||||
fs.BoolVar(&flags.Version, 'v', "version", "Show version information")
|
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:],
|
err = ff.Parse(fs, os.Args[1:],
|
||||||
ff.WithEnvVarPrefix("VBANTXT"),
|
ff.WithEnvVarPrefix("VBANTXT"),
|
||||||
@@ -138,6 +143,22 @@ func run() (func(), error) {
|
|||||||
return nil, nil
|
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)
|
level, err := log.ParseLevel(flags.Loglevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid log level %q", flags.Loglevel)
|
return nil, fmt.Errorf("invalid log level %q", flags.Loglevel)
|
||||||
|
|||||||
3
go.mod
3
go.mod
@@ -3,7 +3,10 @@ module github.com/onyx-and-iris/vbantxt
|
|||||||
go 1.25.0
|
go 1.25.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/StevenACoffman/mango-ff v0.0.0-20260411205343-7f039223efef
|
||||||
github.com/charmbracelet/log v1.0.0
|
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/peterbourgon/ff/v4 v4.0.0-beta.1
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
)
|
)
|
||||||
|
|||||||
6
go.sum
6
go.sum
@@ -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 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
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=
|
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-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 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw=
|
||||||
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
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 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
||||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
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=
|
github.com/pelletier/go-toml/v2 v2.3.0 h1:k59bC/lIZREW0/iVaQR8nDHxVq8OVlIzYCOJf421CaM=
|
||||||
|
|||||||
Reference in New Issue
Block a user