package main import ( "fmt" "log" "os" "git.bth.moi/bth/um/cat" "git.bth.moi/bth/um/cmd" "git.bth.moi/bth/um/last" "git.bth.moi/bth/um/mv" "git.bth.moi/bth/um/next" "git.bth.moi/bth/um/sort" "git.bth.moi/bth/um/tag" ) var helpShort string = fmt.Sprintf("um [%s | %s | %s | %s | %s | %s | %s]", cmd.Next, cmd.Last, cmd.Tag, cmd.Cat, cmd.Sort, cmd.Mv, cmd.Help) var helpLong string = fmt.Sprintf(`%s (U)ltralight zettelkasten for (M)arkdown composition. Each subcommand has a --help | -h flag. https://git.bth.moi/bth/um `, helpShort) func main() { // NOTE: no prefix at all so that I can use log alongside fmt // log : stderr : exit status 1 // fmt : stdout : exit status 0 log.SetFlags(0) if len(os.Args) < 2 { log.Fatalln(helpShort) } arg := cmd.Subcommand(os.Args[1]) // NOTE: just pass what's relevant: args := os.Args[2:] switch arg { case cmd.Next: next.Next(args) case cmd.Last: last.Last(args) case cmd.Tag: tag.Tag(args) case cmd.Cat: cat.Cat(args) case cmd.Sort: sort.Sort(args) case cmd.Mv: mv.Mv(args) case cmd.Help: fmt.Println(helpLong) default: log.Println("um: command not found") log.Fatalln(helpShort) } }