TastyBites/cmd/cmd.go

37 lines
744 B
Go
Raw Permalink Normal View History

2024-04-27 14:01:54 +00:00
package cmd
import (
"fmt"
"os"
)
func Parse() {
if len(os.Args) < 2 {
2024-05-06 16:28:18 +00:00
fmt.Println("Use -h or -help for usage")
2024-04-27 14:01:54 +00:00
os.Exit(1)
}
switch os.Args[1] {
case "run":
run(os.Args[2:])
case "migrate":
migrate(os.Args[2:])
case "downgrade":
downgrade(os.Args[2:])
case "status":
status(os.Args[2:])
2024-04-27 14:01:54 +00:00
case "-h":
2024-05-06 16:28:18 +00:00
fallthrough
case "-help":
2024-04-27 14:01:54 +00:00
fmt.Println("Available commands are:")
fmt.Println(" run: starts the server")
fmt.Println(" migrate: migrates database")
fmt.Println(" downgrade: undoes database migrations")
fmt.Println(" status: checks if there are pending migrations")
2024-04-27 14:01:54 +00:00
fmt.Println("\nTo specific usages, run commandName -h")
default:
2024-05-06 16:28:18 +00:00
fmt.Println("Use -h or -help for usage")
2024-04-27 14:01:54 +00:00
os.Exit(1)
}
}