gum/man/command.go
2022-08-04 12:16:30 -04:00

25 lines
672 B
Go

package man
import (
"fmt"
"github.com/alecthomas/kong"
mangokong "github.com/alecthomas/mango-kong"
"github.com/muesli/roff"
)
// Man is a gum sub-command that generates man pages.
type Man struct{}
// BeforeApply implements Kong BeforeApply hook.
func (m Man) BeforeApply(ctx *kong.Context) error {
// Set the correct man pages description without color escape sequences.
ctx.Model.Help = "A tool for glamorous shell scripts."
man := mangokong.NewManPage(1, ctx.Model)
man = man.WithSection("Copyright", "(C) 2021-2022 Charmbracelet, Inc.\n"+
"Released under MIT license.")
fmt.Fprint(ctx.Stdout, man.Build(roff.NewDocument()))
ctx.Exit(0)
return nil
}