Improve cli command flag help information

This commit is contained in:
Tobie Morgan Hitchcock 2017-11-16 19:46:41 +00:00
parent 0ce8e78577
commit e401ff9b3f
3 changed files with 20 additions and 9 deletions

View file

@ -15,26 +15,35 @@
package cli package cli
var flags = map[string]string{ var flags = map[string]string{
"db": `Database configuration path used for storing data. Available backend stores are memory, rixxdb, or dendrodb. (default "memory").`, "db": `Database configuration path used for storing data. Available backend stores are memory, file, s3, gcs, rixxdb, or dendrodb. (default "memory").`,
"key": `Encryption key to use for intra-cluster communications, and on-disk encryption. For AES-128 encryption use a 16 bit key, for AES-192 encryption use a 24 bit key, and for AES-256 encryption use a 32 bit key.`, "key": `Encryption key to use for intra-cluster communications, and on-disk encryption. For AES-128 encryption use a 16 bit key, for AES-192 encryption use a 24 bit key, and for AES-256 encryption use a 32 bit key.`,
"sync": `A time duration to use when syncing data to persistent storage. To sync data with every write specify '0', otherwise the data will be persisted asynchronously after the specified duration.`,
"join": `A comma-separated list of addresses to use when a new node is joining an existing cluster. For the first node in a cluster, --join should NOT be specified.`, "join": `A comma-separated list of addresses to use when a new node is joining an existing cluster. For the first node in a cluster, --join should NOT be specified.`,
} }
var usage = map[string][]string{ var usage = map[string][]string{
"db": { "db": {
"--db-path memory", "--db-path memory",
"--db-path rixxdb://surreal.db", "--db-path file://surreal.db",
"--db-path logr://path/to/surreal.db",
"--db-path s3://bucket/path/to/surreal.db",
"--db-path gcs://bucket/path/to/surreal.db",
"--db-path dendro://user:pass@192.168.1.100", "--db-path dendro://user:pass@192.168.1.100",
}, },
"key": {
"--key 1hg7dbrma8ghe547",
"--key 1hg7dbrma8ghe5473kghvie6",
"--key 1hg7dbrma8ghe5473kghvie64jgi3ph4",
},
"sync": {
"--db-sync 0",
"--db-sync 5s",
"--db-sync 1m",
},
"join": { "join": {
"--join 10.0.0.1", "--join 10.0.0.1",
"--join 10.0.0.1:33693", "--join 10.0.0.1:33693",
"--join 10.0.0.1:33693,10.0.0.2:33693", "--join 10.0.0.1:33693,10.0.0.2:33693",
"--join 89.13.7.33:33693,example.com:33693", "--join 89.13.7.33:33693,example.com:33693",
}, },
"key": {
"--key 1hg7dbrma8ghe547",
"--key 1hg7dbrma8ghe5473kghvie6",
"--key 1hg7dbrma8ghe5473kghvie64jgi3ph4",
},
} }

View file

@ -143,7 +143,9 @@ func setup() {
opts.Auth.Pass = string(rand.New(20)) opts.Auth.Pass = string(rand.New(20))
} }
// // Ensure that login as
// root can only be from
// specified ip addresses
for _, cidr := range opts.Auth.Addr { for _, cidr := range opts.Auth.Addr {
_, subn, err := net.ParseCIDR(cidr) _, subn, err := net.ParseCIDR(cidr)

View file

@ -81,7 +81,7 @@ func init() {
startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Crt, "db-crt", "", "Path to the certificate file used to connect to the remote database.") startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Crt, "db-crt", "", "Path to the certificate file used to connect to the remote database.")
startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Key, "db-key", "", "Path to the private key file used to connect to the remote database.") startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Key, "db-key", "", "Path to the private key file used to connect to the remote database.")
startCmd.PersistentFlags().StringVar(&opts.DB.Path, "db-path", "", flag("db")) startCmd.PersistentFlags().StringVar(&opts.DB.Path, "db-path", "", flag("db"))
startCmd.PersistentFlags().DurationVar(&opts.DB.Time, "db-sync", 0, "Something here") startCmd.PersistentFlags().DurationVar(&opts.DB.Time, "db-sync", 0, flag("sync"))
startCmd.PersistentFlags().StringSliceVarP(&opts.Node.Join, "join", "j", nil, flag("join")) startCmd.PersistentFlags().StringSliceVarP(&opts.Node.Join, "join", "j", nil, flag("join"))