root cmd gets help subcmd
This commit is contained in:
parent
5b930f4526
commit
d404b3d096
1 changed files with 14 additions and 3 deletions
17
um.go
17
um.go
|
|
@ -17,9 +17,18 @@ const (
|
||||||
next Subcommand = "next"
|
next Subcommand = "next"
|
||||||
last Subcommand = "last"
|
last Subcommand = "last"
|
||||||
sort Subcommand = "sort"
|
sort Subcommand = "sort"
|
||||||
|
help Subcommand = "help"
|
||||||
)
|
)
|
||||||
|
|
||||||
var help string = fmt.Sprintf("um [%s | %s | %s | %s] [--help | -h]", tag, next, last, sort)
|
var helpShort string = fmt.Sprintf("um [%s | %s | %s | %s | %s]", tag, next, last, sort, help)
|
||||||
|
var helpLong string = fmt.Sprintf(`%s
|
||||||
|
|
||||||
|
An (U)ltralight database for (M)arkdown composition.
|
||||||
|
|
||||||
|
Each subcommand has a --help | -h flag.
|
||||||
|
|
||||||
|
https://git.bth.moi/bth/um
|
||||||
|
`, helpShort)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// NOTE: no prefix at all so that I can use log.Fatalf
|
// NOTE: no prefix at all so that I can use log.Fatalf
|
||||||
|
|
@ -28,7 +37,7 @@ func main() {
|
||||||
// TODO: do something useful:
|
// TODO: do something useful:
|
||||||
// run empty tag query?
|
// run empty tag query?
|
||||||
if len(os.Args) < 2 {
|
if len(os.Args) < 2 {
|
||||||
log.Fatalln(help)
|
log.Fatalln(helpShort)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := Subcommand(os.Args[1])
|
cmd := Subcommand(os.Args[1])
|
||||||
|
|
@ -43,8 +52,10 @@ func main() {
|
||||||
tagpkg.Tag(args)
|
tagpkg.Tag(args)
|
||||||
case sort:
|
case sort:
|
||||||
sortpkg.Sort(args)
|
sortpkg.Sort(args)
|
||||||
|
case help:
|
||||||
|
log.Fatalln(helpLong)
|
||||||
default:
|
default:
|
||||||
log.Println("um: command not found")
|
log.Println("um: command not found")
|
||||||
log.Fatalln(help)
|
log.Fatalln(helpShort)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue