-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (31 loc) · 817 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"github.com/alecthomas/kong"
"github.com/mikfreedman/harvey/command"
)
var version = "devel"
var cli struct {
Strip command.Strip `cmd:"" name:"strip"`
Version VersionFlag `name:"version" short:"v" help:"Print version information and quit"`
}
type VersionFlag string
func (v VersionFlag) Decode(ctx *kong.DecodeContext) error { return nil }
func (v VersionFlag) IsBool() bool { return true }
func (v VersionFlag) BeforeApply(app *kong.Kong, vars kong.Vars) error {
fmt.Println(version)
app.Exit(0)
return nil
}
func main() {
ctx := kong.Parse(&cli,
kong.Name("harvey"),
kong.Description("Cleanup Markdown"),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
}),
)
err := ctx.Run()
ctx.FatalIfErrorf(err)
}