Compare commits

..

No commits in common. "e63ad28f74624db82031b8a5a691ae8850e8dd57" and "31973bd5dd5b4b261ae73609e9fa24f02eeea5e3" have entirely different histories.

13
main.go
View File

@ -9,7 +9,6 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings"
_ "modernc.org/sqlite" _ "modernc.org/sqlite"
) )
@ -119,10 +118,6 @@ func exists(path string) (bool, error) {
return false, err return false, err
} }
func printUsage() {
fmt.Fprintf(os.Stderr, "Usage: ./hs9001 <add/search/init/import>\n")
}
func main() { func main() {
var ret int var ret int
flag.IntVar(&ret, "ret", 0, "Return value of the command to add") flag.IntVar(&ret, "ret", 0, "Return value of the command to add")
@ -131,7 +126,7 @@ func main() {
argslen := len(args) argslen := len(args)
if argslen < 1 { if argslen < 1 {
printUsage() fmt.Fprintf(os.Stderr, "Usage: ./hs9001 <add/search/init/import>\n")
return return
} }
@ -157,7 +152,7 @@ func main() {
if argslen < 2 { if argslen < 2 {
fmt.Fprint(os.Stderr, "Please provide the search query\n") fmt.Fprint(os.Stderr, "Please provide the search query\n")
} }
q := strings.Join(args[1:], " ") q := args[1]
search(conn, q) search(conn, q)
os.Exit(23) os.Exit(23)
} else if cmd == "init" { } else if cmd == "init" {
@ -168,9 +163,5 @@ func main() {
initDatabase(conn) initDatabase(conn)
} else if cmd == "import" { } else if cmd == "import" {
importFromStdin(conn) importFromStdin(conn)
} else {
fmt.Fprint(os.Stderr, "Error: Unknown command supplied\n\n")
printUsage()
return
} }
} }