Skip to content

Commit

Permalink
neofs-cli: add check commands positional arguments (#2525)
Browse files Browse the repository at this point in the history
  • Loading branch information
cthulhu-rider authored Aug 25, 2023
2 parents 27a0a93 + f70e000 commit f5d80b0
Show file tree
Hide file tree
Showing 51 changed files with 69 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ minor release, the component will be purged, so be prepared (see `Updating` sect
- SN's version and capacity is announced via the attributes automatically but can be overwritten explicitly (#2455, #602)
- `peapod` command for `neofs-lens` (#2507)
- New CLI exit code for awaiting timeout (#2380)
- Validation of excessive positional arguments to `neofs-cli` commands (#1941)

### Fixed
- `neo-go` RPC connection loss handling (#1337)
Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/accounting/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var accountingBalanceCmd = &cobra.Command{
Use: "balance",
Short: "Get internal balance of NeoFS account",
Long: `Get internal balance of NeoFS account`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx := context.Background()

var idUser user.ID
Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/accounting/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var Cmd = &cobra.Command{
Use: "accounting",
Short: "Operations with accounts and balances",
Long: `Operations with accounts and balances`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
flags := cmd.Flags()

_ = viper.BindPFlag(commonflags.WalletPath, flags.Lookup(commonflags.WalletPath))
Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/acl/extended/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ When both '--rule' and '--file' arguments are used, '--rule' records will be pla
`,
Example: `neofs-cli acl extended create --cid EutHBsdT1YCzHxjCfQHnLPL1vFrkSyLSio4vkphfnEk -f rules.txt --out table.json
neofs-cli acl extended create --cid EutHBsdT1YCzHxjCfQHnLPL1vFrkSyLSio4vkphfnEk -r 'allow get obj:Key=Value others' -r 'deny put others'`,
Run: createEACL,
Args: cobra.NoArgs,
Run: createEACL,
}

func init() {
Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/acl/extended/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
var printEACLCmd = &cobra.Command{
Use: "print",
Short: "Pretty print extended ACL from the file(in text or json format) or for given container.",
Args: cobra.NoArgs,
Run: printEACL,
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/bearer/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ All epoch flags can be specified relative to the current epoch with the +n synta
In this case --` + commonflags.RPC + ` flag should be specified and the epoch in bearer token
is set to current epoch + n.
`,
Run: createToken,
Args: cobra.NoArgs,
Run: createToken,
}

func init() {
Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/container/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ var createContainerCmd = &cobra.Command{
Short: "Create new container",
Long: `Create new container and register it in the NeoFS.
It will be stored in sidechain when inner ring will accepts it.`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := getAwaitContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/container/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var deleteContainerCmd = &cobra.Command{
Short: "Delete existing container",
Long: `Delete existing container.
Only owner of the container has a permission to remove container.`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := getAwaitContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/container/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var getContainerInfoCmd = &cobra.Command{
Use: "get",
Short: "Get container field info",
Long: `Get container field info`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/container/get_eacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var getExtendedACLCmd = &cobra.Command{
Use: "get-eacl",
Short: "Get extended ACL table of container",
Long: `Get extended ACL table of container`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/container/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ var listContainersCmd = &cobra.Command{
Use: "list",
Short: "List all created containers",
Long: "List all created containers",
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/container/list_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ var listContainerObjectsCmd = &cobra.Command{
Use: "list-objects",
Short: "List existing objects in container",
Long: `List existing objects in container`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/container/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var containerNodesCmd = &cobra.Command{
Use: "nodes",
Short: "Show nodes for container",
Long: "Show nodes taking part in a container at the current epoch.",
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/container/set_eacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ var setExtendedACLCmd = &cobra.Command{
Short: "Set new extended ACL table for container",
Long: `Set new extended ACL table for container.
Container ID in EACL table will be substituted with ID from the CLI.`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := getAwaitContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/control/drop_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var dropObjectsCmd = &cobra.Command{
Use: "drop-objects",
Short: "Drop objects from the node's local storage",
Long: "Drop objects from the node's local storage",
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/evacuate_shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var evacuateShardCmd = &cobra.Command{
Use: "evacuate",
Short: "Evacuate objects from shard",
Long: "Evacuate objects from shard to other shards",
Args: cobra.NoArgs,
Run: evacuateShard,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/flush_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var flushCacheCmd = &cobra.Command{
Use: "flush-cache",
Short: "Flush objects from the write-cache to the main storage",
Long: "Flush objects from the write-cache to the main storage",
Args: cobra.NoArgs,
Run: flushCache,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var healthCheckCmd = &cobra.Command{
Use: "healthcheck",
Short: "Health check of the NeoFS node",
Long: "Health check of the NeoFS node. Checks storage node by default, use --ir flag to work with Inner Ring.",
Args: cobra.NoArgs,
Run: healthCheck,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/set_netmap_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var setNetmapStatusCmd = &cobra.Command{
Use: "set-status",
Short: "Set status of the storage node in NeoFS network map",
Long: "Set status of the storage node in NeoFS network map",
Args: cobra.NoArgs,
Run: setNetmapStatus,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/shards_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var dumpShardCmd = &cobra.Command{
Use: "dump",
Short: "Dump objects from shard",
Long: "Dump objects from shard to a file",
Args: cobra.NoArgs,
Run: dumpShard,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/shards_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var listShardsCmd = &cobra.Command{
Use: "list",
Short: "List shards of the storage node",
Long: "List shards of the storage node",
Args: cobra.NoArgs,
Run: listShards,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/shards_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var restoreShardCmd = &cobra.Command{
Use: "restore",
Short: "Restore objects from shard",
Long: "Restore objects from shard to a file",
Args: cobra.NoArgs,
Run: restoreShard,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/shards_set_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ var setShardModeCmd = &cobra.Command{
Use: "set-mode",
Short: "Set work mode of the shard",
Long: "Set work mode of the shard",
Args: cobra.NoArgs,
Run: setShardMode,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/control/synchronize_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var synchronizeTreeCmd = &cobra.Command{
Use: "synchronize-tree",
Short: "Synchronize log for the tree",
Long: "Synchronize log for the tree in an object tree service.",
Args: cobra.NoArgs,
Run: synchronizeTree,
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/netmap/get_epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var getEpochCmd = &cobra.Command{
Use: "epoch",
Short: "Get current epoch number",
Long: "Get current epoch number",
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/netmap/netinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var netInfoCmd = &cobra.Command{
Use: "netinfo",
Short: "Get information about NeoFS network",
Long: "Get information about NeoFS network",
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/netmap/nodeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ var nodeInfoCmd = &cobra.Command{
Use: "nodeinfo",
Short: "Get target node info",
Long: `Get target node info`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/netmap/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var snapshotCmd = &cobra.Command{
Use: "snapshot",
Short: "Request current local snapshot of the network map",
Long: `Request current local snapshot of the network map`,
Run: func(cmd *cobra.Command, args []string) {
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/object/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var objectDelCmd = &cobra.Command{
Aliases: []string{"del"},
Short: "Delete object from NeoFS",
Long: "Delete object from NeoFS",
Args: cobra.NoArgs,
Run: deleteObject,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/object/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var objectGetCmd = &cobra.Command{
Use: "get",
Short: "Get object from NeoFS",
Long: "Get object from NeoFS",
Args: cobra.NoArgs,
Run: getObject,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/object/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var objectHashCmd = &cobra.Command{
Use: "hash",
Short: "Get object hash",
Long: "Get object hash",
Args: cobra.NoArgs,
Run: getObjectHash,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/object/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var objectHeadCmd = &cobra.Command{
Use: "head",
Short: "Get object header",
Long: "Get object header",
Args: cobra.NoArgs,
Run: getObjectHeader,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/object/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var objectLockCmd = &cobra.Command{
Use: "lock",
Short: "Lock object in container",
Long: "Lock object in container",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := commonflags.GetCommandContext(cmd)
defer cancel()
Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/object/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var objectPutCmd = &cobra.Command{
Use: "put",
Short: "Put object to NeoFS",
Long: "Put object to NeoFS",
Args: cobra.NoArgs,
Run: putObject,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/object/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var objectRangeCmd = &cobra.Command{
Use: "range",
Short: "Get payload range data of an object",
Long: "Get payload range data of an object",
Args: cobra.NoArgs,
Run: getObjectRange,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/object/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
Use: "search",
Short: "Search object",
Long: "Search object",
Args: cobra.NoArgs,
Run: searchObject,
}
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/neofs-cli/modules/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ It contains commands for interaction with NeoFS nodes using different versions
of neofs-api and some useful utilities for compiling ACL rules from JSON
notation, managing container access through protocol gates, querying network map
and much more!`,
Run: entryPoint,
Args: cobra.NoArgs,
Run: entryPoint,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/session/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const defaultLifetime = 10
var createCmd = &cobra.Command{
Use: "create",
Short: "Create session token",
Args: cobra.NoArgs,
Run: createSession,
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.WalletPath, cmd.Flags().Lookup(commonflags.WalletPath))
Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/storagegroup/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var sgDelCmd = &cobra.Command{
Use: "delete",
Short: "Delete storage group from NeoFS",
Long: "Delete storage group from NeoFS",
Args: cobra.NoArgs,
Run: delSG,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/storagegroup/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var sgGetCmd = &cobra.Command{
Use: "get",
Short: "Get storage group from NeoFS",
Long: "Get storage group from NeoFS",
Args: cobra.NoArgs,
Run: getSG,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/storagegroup/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var sgListCmd = &cobra.Command{
Use: "list",
Short: "List storage groups in NeoFS container",
Long: "List storage groups in NeoFS container",
Args: cobra.NoArgs,
Run: listSG,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/storagegroup/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var sgPutCmd = &cobra.Command{
Use: "put",
Short: "Put storage group to NeoFS",
Long: "Put storage group to NeoFS",
Args: cobra.NoArgs,
Run: putSG,
}

Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/tree/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var addCmd = &cobra.Command{
Use: "add",
Short: "Add a node to the tree service",
Run: add,
Args: cobra.NoArgs,
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
commonflags.Bind(cmd)
},
Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/tree/add_by_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
var addByPathCmd = &cobra.Command{
Use: "add-by-path",
Short: "Add a node by the path",
Args: cobra.NoArgs,
Run: addByPath,
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
commonflags.Bind(cmd)
Expand Down
1 change: 1 addition & 0 deletions cmd/neofs-cli/modules/tree/get_by_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
var getByPathCmd = &cobra.Command{
Use: "get-by-path",
Short: "Get a node by its path",
Args: cobra.NoArgs,
Run: getByPath,
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
commonflags.Bind(cmd)
Expand Down
Loading

0 comments on commit f5d80b0

Please sign in to comment.