2022-07-11 17:05:58 +02:00
|
|
|
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.
|
2022-08-01 17:50:02 +02:00
|
|
|
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)
|
2023-05-12 03:14:22 +02:00
|
|
|
man = man.WithSection("Copyright", "(C) 2022-2023 Charmbracelet, Inc.\n"+
|
2022-07-11 17:05:58 +02:00
|
|
|
"Released under MIT license.")
|
2022-08-01 17:50:02 +02:00
|
|
|
fmt.Fprint(ctx.Stdout, man.Build(roff.NewDocument()))
|
|
|
|
ctx.Exit(0)
|
2022-07-11 17:05:58 +02:00
|
|
|
return nil
|
|
|
|
}
|