Skip to content

Commit

Permalink
Fix #1 - print usage without arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshi committed Oct 30, 2016
1 parent 7fa7909 commit f16f05b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"flag"
// "fmt"
"fmt"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
Expand Down Expand Up @@ -75,10 +75,15 @@ func DockerOutput(arg ...string) (string, error) {
func cbMain() (exitCode int) {
log.SetFlags(log.LstdFlags | log.Lshortfile)
// Take arguments and options
source := os.Args[1]
log.Println("source:", source)
flags := flag.NewFlagSet("", flag.ExitOnError)
configPath := flags.String("config", "", "The .yaml or .json file to use for build configuration.")
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "Usage: %s SOURCE -config CONFIG.(yml|json)\n", os.Args[0])
flags.PrintDefaults()
return 1
}
source := os.Args[1]
log.Println("source:", source)
flags.Parse(os.Args[2:])

// Read the config file
Expand Down

0 comments on commit f16f05b

Please sign in to comment.