combo/main.go

41 lines
601 B
Go
Raw Normal View History

2020-08-23 03:20:12 +03:00
package main
import(
"fmt"
"os"
"github.com/k1574/utf8tmpl/tmpl"
2020-08-30 00:46:11 +03:00
"github.com/k1574/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)
}