1
0
miroir de https://github.com/quitesimpleorg/hs9001.git synchronisé 2024-11-25 02:22:37 +01:00

Print usage also when an invalid command is supplied

Cette révision appartient à :
Albert S. 2021-03-22 19:50:27 +01:00
Parent eb0612864d
révision e63ad28f74

10
main.go
Voir le fichier

@ -119,6 +119,10 @@ func exists(path string) (bool, error) {
return false, err
}
func printUsage() {
fmt.Fprintf(os.Stderr, "Usage: ./hs9001 <add/search/init/import>\n")
}
func main() {
var ret int
flag.IntVar(&ret, "ret", 0, "Return value of the command to add")
@ -127,7 +131,7 @@ func main() {
argslen := len(args)
if argslen < 1 {
fmt.Fprintf(os.Stderr, "Usage: ./hs9001 <add/search/init/import>\n")
printUsage()
return
}
@ -164,5 +168,9 @@ func main() {
initDatabase(conn)
} else if cmd == "import" {
importFromStdin(conn)
} else {
fmt.Fprint(os.Stderr, "Error: Unknown command supplied\n\n")
printUsage()
return
}
}