Start making help slightly configurable.

This commit is contained in:
Alec Thomas
2018-06-20 21:51:56 +10:00
parent 3a2f3eebdd
commit 653531d6bc
9 changed files with 173 additions and 77 deletions
+10 -16
View File
@@ -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":
}
}