Start making help slightly configurable.
This commit is contained in:
+10
-16
@@ -1,15 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
// nolint: govet
|
||||
var CLI struct {
|
||||
var cli struct {
|
||||
Debug bool `help:"Debug mode."`
|
||||
|
||||
Rm struct {
|
||||
@@ -17,19 +12,18 @@ var CLI struct {
|
||||
Force bool `help:"Force removal." short:"f"`
|
||||
Recursive bool `help:"Recursively remove files." short:"r"`
|
||||
|
||||
Paths []string `arg help:"Paths to remove." type:"path"`
|
||||
} `cmd help:"Remove files."`
|
||||
Paths []string `arg:"" help:"Paths to remove." type:"path"`
|
||||
} `cmd:"" help:"Remove files."`
|
||||
|
||||
Ls struct {
|
||||
Paths []string `arg optional help:"Paths to list." type:"path"`
|
||||
} `cmd help:"List paths."`
|
||||
Paths []string `arg:"" optional:"" help:"Paths to list." type:"path"`
|
||||
} `cmd:"" help:"List paths."`
|
||||
}
|
||||
|
||||
func main() {
|
||||
app := kong.Must(&CLI, kong.Description("A shell-like example app."))
|
||||
cmd, err := app.Parse(os.Args[1:])
|
||||
app.FatalIfErrorf(err)
|
||||
s, _ := json.Marshal(&CLI)
|
||||
fmt.Println(cmd)
|
||||
fmt.Println(string(s))
|
||||
cmd := kong.Parse(&cli, kong.Description("A shell-like example app."), kong.HelpOptions(kong.CompactHelp()))
|
||||
switch cmd {
|
||||
case "rm":
|
||||
case "ls":
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user