Commits

Miki Tebeka committed 1590fe9

root as first parameter

  • Participants
  • Parent commits 49e5026

Comments (0)

Files changed (2)

 }
 
 func main() {
-	var root string
 	var showVersion bool
 
-	flag.StringVar(&root, "root", "", "root direcotry")
 	flag.BoolVar(&showVersion, "version", false, "show version and exit")
+	flag.Usage = func() {
+		fmt.Fprintf(os.Stderr, "usage: %s RESOURCE_DIR\n", os.Args[0])
+		flag.PrintDefaults()
+	}
 	flag.Parse()
 
 	if showVersion {
 		os.Exit(0)
 	}
 
-	if len(root) == 0 {
-		die("<root> is required")
+	if flag.NArg() != 1 {
+		die("wrong number of parameters")
 	}
 
+	root := flag.Arg(0)
+
 	if !dirExists(root) {
 		die("%s is not a directory", root)
 	}

File nrsc_test.go

 	os.Chdir(root)
 	defer os.Chdir(cwd)
 
-	cmd := exec.Command(path("nrsc"), "-root", path("test-resources"))
+	cmd := exec.Command(path("nrsc"), path("test-resources"))
 	if err := cmd.Run(); err != nil {
 		panic(err)
 	}