Browse Source

etcdmain: print error when non-flag args remain

Yicheng Qin 10 years ago
parent
commit
0ac05e310e
2 changed files with 4 additions and 1 deletions
  1. 3 0
      etcdmain/config.go
  2. 1 1
      etcdmain/etcd.go

+ 3 - 0
etcdmain/config.go

@@ -212,6 +212,9 @@ func (cfg *config) Parse(arguments []string) error {
 	default:
 		os.Exit(2)
 	}
+	if len(cfg.FlagSet.Args()) != 0 {
+		return fmt.Errorf("'%s' is not a valid flag", cfg.FlagSet.Arg(0))
+	}
 
 	if cfg.printVersion {
 		fmt.Println("etcd version", version.Version)

+ 1 - 1
etcdmain/etcd.go

@@ -56,7 +56,7 @@ func Main() {
 	cfg := NewConfig()
 	err := cfg.Parse(os.Args[1:])
 	if err != nil {
-		log.Printf("etcd: error verifying flags, %v", err)
+		log.Printf("etcd: error verifying flags, %v. See 'etcd -help'.", err)
 		os.Exit(2)
 	}