etcdctl: fill out ArgsUsage fields for help

USAGE in help now names positional arguments (e.g., "member remove <memberID>"
instead of "member remove [arguments...]")

Fixes #4021
release-2.3
Anthony Romano 2015-12-18 17:22:17 -08:00
parent 9ee9e552e6
commit 2974c4ec27
19 changed files with 121 additions and 87 deletions

View File

@ -29,14 +29,16 @@ func NewAuthCommands() cli.Command {
Usage: "overall auth controls", Usage: "overall auth controls",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
{ {
Name: "enable", Name: "enable",
Usage: "enable auth access controls", Usage: "enable auth access controls",
Action: actionAuthEnable, ArgsUsage: " ",
Action: actionAuthEnable,
}, },
{ {
Name: "disable", Name: "disable",
Usage: "disable auth access controls", Usage: "disable auth access controls",
Action: actionAuthDisable, ArgsUsage: " ",
Action: actionAuthDisable,
}, },
}, },
} }

View File

@ -32,8 +32,9 @@ import (
func NewBackupCommand() cli.Command { func NewBackupCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "backup", Name: "backup",
Usage: "backup an etcd directory", Usage: "backup an etcd directory",
ArgsUsage: " ",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.StringFlag{Name: "data-dir", Value: "", Usage: "Path to the etcd data dir"}, cli.StringFlag{Name: "data-dir", Value: "", Usage: "Path to the etcd data dir"},
cli.StringFlag{Name: "backup-dir", Value: "", Usage: "Path to the backup dir"}, cli.StringFlag{Name: "backup-dir", Value: "", Usage: "Path to the backup dir"},

View File

@ -30,8 +30,9 @@ import (
func NewClusterHealthCommand() cli.Command { func NewClusterHealthCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "cluster-health", Name: "cluster-health",
Usage: "check the health of the etcd cluster", Usage: "check the health of the etcd cluster",
ArgsUsage: " ",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{Name: "forever", Usage: "forever check the health every 10 second until CTRL+C"}, cli.BoolFlag{Name: "forever", Usage: "forever check the health every 10 second until CTRL+C"},
}, },

View File

@ -30,8 +30,9 @@ import (
// NewExecWatchCommand returns the CLI command for "exec-watch". // NewExecWatchCommand returns the CLI command for "exec-watch".
func NewExecWatchCommand() cli.Command { func NewExecWatchCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "exec-watch", Name: "exec-watch",
Usage: "watch a key for changes and exec an executable", Usage: "watch a key for changes and exec an executable",
ArgsUsage: "<key> <command> [args...]",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.IntFlag{Name: "after-index", Value: 0, Usage: "watch after the given index"}, cli.IntFlag{Name: "after-index", Value: 0, Usage: "watch after the given index"},
cli.BoolFlag{Name: "recursive", Usage: "watch all values for key and child keys"}, cli.BoolFlag{Name: "recursive", Usage: "watch all values for key and child keys"},

View File

@ -26,8 +26,9 @@ import (
// NewGetCommand returns the CLI command for "get". // NewGetCommand returns the CLI command for "get".
func NewGetCommand() cli.Command { func NewGetCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "get", Name: "get",
Usage: "retrieve the value of a key", Usage: "retrieve the value of a key",
ArgsUsage: "<key>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"}, cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"},
cli.BoolFlag{Name: "quorum", Usage: "require quorum for get request"}, cli.BoolFlag{Name: "quorum", Usage: "require quorum for get request"},

View File

@ -36,8 +36,9 @@ type set struct {
func NewImportSnapCommand() cli.Command { func NewImportSnapCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "import", Name: "import",
Usage: "import a snapshot to a cluster", Usage: "import a snapshot to a cluster",
ArgsUsage: " ",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.StringFlag{Name: "snap", Value: "", Usage: "Path to the valid etcd 0.4.x snapshot."}, cli.StringFlag{Name: "snap", Value: "", Usage: "Path to the valid etcd 0.4.x snapshot."},
cli.StringSliceFlag{Name: "hidden", Value: new(cli.StringSlice), Usage: "Hidden key spaces to import from snapshot"}, cli.StringSliceFlag{Name: "hidden", Value: new(cli.StringSlice), Usage: "Hidden key spaces to import from snapshot"},

View File

@ -23,8 +23,9 @@ import (
func NewLsCommand() cli.Command { func NewLsCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "ls", Name: "ls",
Usage: "retrieve a directory", Usage: "retrieve a directory",
ArgsUsage: "[key]",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"}, cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"},
cli.BoolFlag{Name: "recursive", Usage: "returns all key names recursively for the given path"}, cli.BoolFlag{Name: "recursive", Usage: "returns all key names recursively for the given path"},

View File

@ -28,24 +28,28 @@ func NewMemberCommand() cli.Command {
Usage: "member add, remove and list subcommands", Usage: "member add, remove and list subcommands",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
{ {
Name: "list", Name: "list",
Usage: "enumerate existing cluster members", Usage: "enumerate existing cluster members",
Action: actionMemberList, ArgsUsage: " ",
Action: actionMemberList,
}, },
{ {
Name: "add", Name: "add",
Usage: "add a new member to the etcd cluster", Usage: "add a new member to the etcd cluster",
Action: actionMemberAdd, ArgsUsage: "<name> <peerURL>",
Action: actionMemberAdd,
}, },
{ {
Name: "remove", Name: "remove",
Usage: "remove an existing member from the etcd cluster", Usage: "remove an existing member from the etcd cluster",
Action: actionMemberRemove, ArgsUsage: "<memberID>",
Action: actionMemberRemove,
}, },
{ {
Name: "update", Name: "update",
Usage: "update an existing member in the etcd cluster", Usage: "update an existing member in the etcd cluster",
Action: actionMemberUpdate, ArgsUsage: "<memberID> <peerURLs>",
Action: actionMemberUpdate,
}, },
}, },
} }

View File

@ -26,8 +26,9 @@ import (
// NewMakeCommand returns the CLI command for "mk". // NewMakeCommand returns the CLI command for "mk".
func NewMakeCommand() cli.Command { func NewMakeCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "mk", Name: "mk",
Usage: "make a new key with a given value", Usage: "make a new key with a given value",
ArgsUsage: "<key> <value>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"}, cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
}, },

View File

@ -25,8 +25,9 @@ import (
// NewMakeDirCommand returns the CLI command for "mkdir". // NewMakeDirCommand returns the CLI command for "mkdir".
func NewMakeDirCommand() cli.Command { func NewMakeDirCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "mkdir", Name: "mkdir",
Usage: "make a new directory", Usage: "make a new directory",
ArgsUsage: "<key>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"}, cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
}, },

View File

@ -24,8 +24,9 @@ import (
// NewRemoveCommand returns the CLI command for "rm". // NewRemoveCommand returns the CLI command for "rm".
func NewRemoveCommand() cli.Command { func NewRemoveCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "rm", Name: "rm",
Usage: "remove a key or a directory", Usage: "remove a key or a directory",
ArgsUsage: "<key>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{Name: "dir", Usage: "removes the key if it is an empty directory or a key-value pair"}, cli.BoolFlag{Name: "dir", Usage: "removes the key if it is an empty directory or a key-value pair"},
cli.BoolFlag{Name: "recursive", Usage: "removes the key and all child keys(if it is a directory)"}, cli.BoolFlag{Name: "recursive", Usage: "removes the key and all child keys(if it is a directory)"},

View File

@ -24,8 +24,9 @@ import (
// NewRemoveCommand returns the CLI command for "rmdir". // NewRemoveCommand returns the CLI command for "rmdir".
func NewRemoveDirCommand() cli.Command { func NewRemoveDirCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "rmdir", Name: "rmdir",
Usage: "removes the key if it is an empty directory or a key-value pair", Usage: "removes the key if it is an empty directory or a key-value pair",
ArgsUsage: "<key>",
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
rmdirCommandFunc(c, mustNewKeyAPI(c)) rmdirCommandFunc(c, mustNewKeyAPI(c))
}, },

View File

@ -31,28 +31,33 @@ func NewRoleCommands() cli.Command {
Usage: "role add, grant and revoke subcommands", Usage: "role add, grant and revoke subcommands",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
{ {
Name: "add", Name: "add",
Usage: "add a new role for the etcd cluster", Usage: "add a new role for the etcd cluster",
Action: actionRoleAdd, ArgsUsage: "<role> ",
Action: actionRoleAdd,
}, },
{ {
Name: "get", Name: "get",
Usage: "get details for a role", Usage: "get details for a role",
Action: actionRoleGet, ArgsUsage: "<role>",
Action: actionRoleGet,
}, },
{ {
Name: "list", Name: "list",
Usage: "list all roles", Usage: "list all roles",
Action: actionRoleList, ArgsUsage: " ",
Action: actionRoleList,
}, },
{ {
Name: "remove", Name: "remove",
Usage: "remove a role from the etcd cluster", Usage: "remove a role from the etcd cluster",
Action: actionRoleRemove, ArgsUsage: "<role>",
Action: actionRoleRemove,
}, },
{ {
Name: "grant", Name: "grant",
Usage: "grant path matches to an etcd role", Usage: "grant path matches to an etcd role",
ArgsUsage: "<role>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.StringFlag{Name: "path", Value: "", Usage: "Path granted for the role to access"}, cli.StringFlag{Name: "path", Value: "", Usage: "Path granted for the role to access"},
cli.BoolFlag{Name: "read", Usage: "Grant read-only access"}, cli.BoolFlag{Name: "read", Usage: "Grant read-only access"},
@ -62,8 +67,9 @@ func NewRoleCommands() cli.Command {
Action: actionRoleGrant, Action: actionRoleGrant,
}, },
{ {
Name: "revoke", Name: "revoke",
Usage: "revoke path matches for an etcd role", Usage: "revoke path matches for an etcd role",
ArgsUsage: "<role>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.StringFlag{Name: "path", Value: "", Usage: "Path revoked for the role to access"}, cli.StringFlag{Name: "path", Value: "", Usage: "Path revoked for the role to access"},
cli.BoolFlag{Name: "read", Usage: "Revoke read access"}, cli.BoolFlag{Name: "read", Usage: "Revoke read access"},

View File

@ -26,8 +26,9 @@ import (
// NewSetCommand returns the CLI command for "set". // NewSetCommand returns the CLI command for "set".
func NewSetCommand() cli.Command { func NewSetCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "set", Name: "set",
Usage: "set the value of a key", Usage: "set the value of a key",
ArgsUsage: "<key> <value>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"}, cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
cli.StringFlag{Name: "swap-with-value", Value: "", Usage: "previous value"}, cli.StringFlag{Name: "swap-with-value", Value: "", Usage: "previous value"},

View File

@ -22,8 +22,9 @@ import (
// NewSetDirCommand returns the CLI command for "setDir". // NewSetDirCommand returns the CLI command for "setDir".
func NewSetDirCommand() cli.Command { func NewSetDirCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "setdir", Name: "setdir",
Usage: "create a new or existing directory", Usage: "create a new or existing directory",
ArgsUsage: "<key>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"}, cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
}, },

View File

@ -26,8 +26,9 @@ import (
// NewUpdateCommand returns the CLI command for "update". // NewUpdateCommand returns the CLI command for "update".
func NewUpdateCommand() cli.Command { func NewUpdateCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "update", Name: "update",
Usage: "update an existing key with a given value", Usage: "update an existing key with a given value",
ArgsUsage: "<key> <value>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"}, cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
}, },

View File

@ -26,8 +26,9 @@ import (
// NewUpdateDirCommand returns the CLI command for "updatedir". // NewUpdateDirCommand returns the CLI command for "updatedir".
func NewUpdateDirCommand() cli.Command { func NewUpdateDirCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "updatedir", Name: "updatedir",
Usage: "update an existing directory", Usage: "update an existing directory",
ArgsUsage: "<key> <value>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"}, cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
}, },

View File

@ -32,41 +32,48 @@ func NewUserCommands() cli.Command {
Usage: "user add, grant and revoke subcommands", Usage: "user add, grant and revoke subcommands",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
{ {
Name: "add", Name: "add",
Usage: "add a new user for the etcd cluster", Usage: "add a new user for the etcd cluster",
Action: actionUserAdd, ArgsUsage: "<user>",
Action: actionUserAdd,
}, },
{ {
Name: "get", Name: "get",
Usage: "get details for a user", Usage: "get details for a user",
Action: actionUserGet, ArgsUsage: "<user>",
Action: actionUserGet,
}, },
{ {
Name: "list", Name: "list",
Usage: "list all current users", Usage: "list all current users",
Action: actionUserList, ArgsUsage: "<user>",
Action: actionUserList,
}, },
{ {
Name: "remove", Name: "remove",
Usage: "remove a user for the etcd cluster", Usage: "remove a user for the etcd cluster",
Action: actionUserRemove, ArgsUsage: "<user>",
Action: actionUserRemove,
}, },
{ {
Name: "grant", Name: "grant",
Usage: "grant roles to an etcd user", Usage: "grant roles to an etcd user",
Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}}, ArgsUsage: "<user>",
Action: actionUserGrant, Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}},
Action: actionUserGrant,
}, },
{ {
Name: "revoke", Name: "revoke",
Usage: "revoke roles for an etcd user", Usage: "revoke roles for an etcd user",
Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}}, ArgsUsage: "<user>",
Action: actionUserRevoke, Flags: []cli.Flag{cli.StringSliceFlag{Name: "roles", Value: new(cli.StringSlice), Usage: "List of roles to grant or revoke"}},
Action: actionUserRevoke,
}, },
{ {
Name: "passwd", Name: "passwd",
Usage: "change password for a user", Usage: "change password for a user",
Action: actionUserPasswd, ArgsUsage: "<user>",
Action: actionUserPasswd,
}, },
}, },
} }

View File

@ -28,8 +28,9 @@ import (
// NewWatchCommand returns the CLI command for "watch". // NewWatchCommand returns the CLI command for "watch".
func NewWatchCommand() cli.Command { func NewWatchCommand() cli.Command {
return cli.Command{ return cli.Command{
Name: "watch", Name: "watch",
Usage: "watch a key for changes", Usage: "watch a key for changes",
ArgsUsage: "<key>",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{Name: "forever", Usage: "forever watch a key until CTRL+C"}, cli.BoolFlag{Name: "forever", Usage: "forever watch a key until CTRL+C"},
cli.IntFlag{Name: "after-index", Value: 0, Usage: "watch after the given index"}, cli.IntFlag{Name: "after-index", Value: 0, Usage: "watch after the given index"},