@@ -25,39 +25,39 @@ type database struct {
25
25
func main () {
26
26
usr , err := user .Current ()
27
27
if err != nil {
28
- log . Fatalf ("Couldn't obtain the current user err=%v" , err )
28
+ usage ("Couldn't obtain the current user err=%v" , err )
29
29
}
30
30
31
31
databasesFile := usr .HomeDir + "/.databases.json"
32
32
databases := map [string ]database {}
33
33
34
34
byts , err := ioutil .ReadFile (databasesFile )
35
35
if err != nil {
36
- log . Fatalf ("Couldn't read [%v] file. err=%v" , databasesFile , err )
36
+ usage ("Couldn't read [%v] file. err=%v" , databasesFile , err )
37
37
}
38
38
39
39
err = json .Unmarshal (byts , & databases )
40
40
if err != nil {
41
- log . Fatalf ("Couldn't unmarshal [%v] file. err=%v" , databasesFile , err )
41
+ usage ("Couldn't unmarshal [%v] file. err=%v" , databasesFile , err )
42
42
}
43
43
44
44
if len (databases ) == 0 {
45
- log . Fatalf ("Couldn't find any database configurations in [%v] file." , databasesFile )
45
+ usage ("Couldn't find any database configurations in [%v] file." , databasesFile )
46
46
}
47
47
48
48
sql := readInput (os .Stdin )
49
49
if len (sql ) <= 3 {
50
- log . Fatal ("No SQL to run. Exiting." )
50
+ usage ("No SQL to run. Exiting." )
51
51
}
52
52
53
53
if len (os .Args [1 :]) == 0 {
54
- log . Fatal ("Target database unspecified; where should I run the query?" )
54
+ usage ("Target database unspecified; where should I run the query?" )
55
55
}
56
56
57
57
targetDatabases := []string {}
58
58
for _ , k := range os .Args [1 :] {
59
59
if _ , ok := databases [k ]; k != "all" && ! ok {
60
- log . Fatalf ("Target database unknown: [%v]" , k )
60
+ usage ("Target database unknown: [%v]" , k )
61
61
}
62
62
if k == "all" {
63
63
targetDatabases = nil
0 commit comments