combo/main.go

41 lines
567 B
Go
Raw Normal View History

2020-08-23 03:20:12 +03:00
package main
import(
"fmt"
"os"
2021-06-02 02:05:18 +03:00
"utf8tmpl/tmpl"
"utf8tmpl/pin"
2020-08-23 03:20:12 +03:00
)
func main() {
var(
utilName string
args []string
)
utilsMap := map[string] interface{} {
"tmpl" : tmpl.Run,
2020-08-30 00:46:11 +03:00
"pin" : pin.Run,
2020-08-23 03:20:12 +03:00
}
if len(os.Args)<2 {
for k, _ := range utilsMap {
fmt.Printf("%s\n", k)
}
os.Exit(0)
} else {
utilName = os.Args[1]
args = os.Args[1:]
}
if _, ok := utilsMap[utilName] ; !ok {
fmt.Printf("%s: %s: no such util\n", os.Args[0], utilName )
os.Exit(1)
}
status := utilsMap[utilName].(func([]string) int )(args)
os.Exit(status)
}