Skip to content

Commit

Permalink
Checks for arguments before consuming STDIN. #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariano Gappa committed Feb 26, 2017
1 parent 58bd0ba commit ebcc93d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ type database struct {
func main() {
databases := mustReadDatabasesConfigFile()

if len(os.Args[1:]) == 0 {
usage("Target database unspecified; where should I run the query?")
}

sql := readInput(os.Stdin)
if len(sql) <= 3 {
usage("No SQL to run. Exiting.")
}

if len(os.Args[1:]) == 0 {
usage("Target database unspecified; where should I run the query?")
}

targetDatabases := []string{}
for _, k := range os.Args[1:] {
if _, ok := databases[k]; k != "all" && !ok {
Expand Down
2 changes: 1 addition & 1 deletion usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ e.g.
echo "SELECT * FROM users WHERE name = 'John'" | sql all
For more detailed help, please go to: https://github.com/MarianoGappa/sql
For more detailed help, please go to: https://github.com/marianogappa/sql
`)
os.Exit(1)
}

0 comments on commit ebcc93d

Please sign in to comment.