Browse Source

cmd/utils: add NewApp

Felix Lange 10 years ago
parent
commit
73d1ebe244
2 changed files with 12 additions and 5 deletions
  1. 1 5
      cmd/ethereum/main.go
  2. 11 0
      cmd/utils/flags.go

+ 1 - 5
cmd/ethereum/main.go

@@ -45,12 +45,10 @@ const (
 
 var (
 	clilogger = logger.NewLogger("CLI")
-	app       = cli.NewApp()
+	app       = utils.NewApp(Version, "the go-ethereum command line interface")
 )
 
 func init() {
-	app.Version = Version
-	app.Usage = "the go-ethereum command-line client"
 	app.Action = run
 	app.HideVersion = true // we have a command to print the version
 	app.Commands = []cli.Command{
@@ -107,8 +105,6 @@ runtime will execute the file and exit.
 			Usage:  `import a blockchain file`,
 		},
 	}
-	app.Author = ""
-	app.Email = ""
 	app.Flags = []cli.Flag{
 		utils.BootnodesFlag,
 		utils.DataDirFlag,

+ 11 - 0
cmd/utils/flags.go

@@ -19,6 +19,17 @@ import (
 	"github.com/ethereum/go-ethereum/p2p/nat"
 )
 
+// NewApp creates an app with sane defaults.
+func NewApp(version, usage string) *cli.App {
+	app := cli.NewApp()
+	app.Name = path.Base(os.Args[0])
+	app.Author = ""
+	app.Email = ""
+	app.Version = version
+	app.Usage = usage
+	return app
+}
+
 // These are all the command line flags we support.
 // If you add to this list, please remember to include the
 // flag in the appropriate command definition.