grim/hgkeeper

ebc5f568d629
Add a note about downloads and pgp verification to the readme
package hg
import (
"github.com/alecthomas/kong"
"github.com/kballard/go-shellquote"
)
type CommandArguments struct {
Hg struct {
Repo string `kong:"flag,short='R'"`
Serve struct {
Stdio bool `kong:"flag,name='stdio'"`
} `kong:"cmd"`
Init struct {
Repo string `kong:"arg"`
} `kong:"cmd"`
} `kong:"cmd"`
}
func ParseCommandArguments(cmd string) (string, CommandArguments, error) {
values := CommandArguments{}
args, err := shellquote.Split(cmd)
if err != nil {
return "", values, err
}
parser := kong.Must(&values)
ctx, err := parser.Parse(args)
if err != nil {
return "", values, err
}
return ctx.Command(), values, nil
}