40 lines
731 B
Go
40 lines
731 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func commandsUsage() string {
|
|
return fmt.Sprintf(
|
|
`commands:
|
|
env %v
|
|
path %v
|
|
time %v
|
|
week %v
|
|
`, commandEnvDescription, commandPathDescription, commandTimeDescription, commandWeekDescription)
|
|
}
|
|
|
|
func main() {
|
|
if len(os.Args) >= 2 {
|
|
switch os.Args[1] {
|
|
case "env":
|
|
commandEnv(os.Args[1:])
|
|
case "path":
|
|
commandPath(os.Args[1:])
|
|
case "time":
|
|
commandTime(os.Args[1:])
|
|
case "week":
|
|
commandWeek(os.Args[1:])
|
|
default:
|
|
fmt.Printf("unknow command `%v`\n\n", os.Args[1])
|
|
fmt.Printf("%v", commandsUsage())
|
|
os.Exit(1)
|
|
}
|
|
} else {
|
|
fmt.Println("Personal scripts set written in Golang\n")
|
|
fmt.Printf("%v", commandsUsage())
|
|
}
|
|
|
|
}
|