diff --git a/CHANGELOG.md b/CHANGELOG.md index b472a3c25..f2cd7c3d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Changelog for NeoFS Node ### Added ### Changed +- `object lock` command reads CID and OID the same way other commands do (#1971) + ### Fixed - Open FSTree in sync mode by default (#1992) - `neofs-cli container nodes`'s output (#1991) @@ -13,6 +15,7 @@ Changelog for NeoFS Node ### Removed ### Updated ### Updating from v0.34.0 +Pass CID and OID parameters via the `--cid` and `--oid` flags, not as the command arguments. ## [0.34.0] - 2022-10-31 - Marado (마라도, 馬羅島) diff --git a/cmd/neofs-cli/modules/object/lock.go b/cmd/neofs-cli/modules/object/lock.go index 2c76020d0..9f952d4d1 100644 --- a/cmd/neofs-cli/modules/object/lock.go +++ b/cmd/neofs-cli/modules/object/lock.go @@ -21,22 +21,22 @@ import ( // object lock command. var objectLockCmd = &cobra.Command{ - Use: "lock CONTAINER OBJECT...", + Use: "lock", Short: "Lock object in container", Long: "Lock object in container", - Args: cobra.MinimumNArgs(2), - Run: func(cmd *cobra.Command, args []string) { - var cnr cid.ID + Run: func(cmd *cobra.Command, _ []string) { + cidRaw, _ := cmd.Flags().GetString("cid") - err := cnr.DecodeString(args[0]) + var cnr cid.ID + err := cnr.DecodeString(cidRaw) common.ExitOnErr(cmd, "Incorrect container arg: %v", err) - argsList := args[1:] + oidsRaw, _ := cmd.Flags().GetStringSlice("oid") - lockList := make([]oid.ID, len(argsList)) + lockList := make([]oid.ID, len(oidsRaw)) - for i := range argsList { - err = lockList[i].DecodeString(argsList[i]) + for i := range oidsRaw { + err = lockList[i].DecodeString(oidsRaw[i]) common.ExitOnErr(cmd, fmt.Sprintf("Incorrect object arg #%d: %%v", i+1), err) } @@ -94,7 +94,16 @@ func initCommandObjectLock() { commonflags.Init(objectLockCmd) initFlagSession(objectLockCmd, "PUT") - objectLockCmd.Flags().Uint64P(commonflags.ExpireAt, "e", 0, "Lock expiration epoch") - objectLockCmd.Flags().Uint64(commonflags.Lifetime, 0, "Lock lifetime") + ff := objectLockCmd.Flags() + + ff.String("cid", "", "Container ID") + _ = objectLockCmd.MarkFlagRequired("cid") + + ff.StringSlice("oid", nil, "Object ID") + _ = objectLockCmd.MarkFlagRequired("oid") + + ff.Uint64P(commonflags.ExpireAt, "e", 0, "Lock expiration epoch") + + ff.Uint64(commonflags.Lifetime, 0, "Lock lifetime") objectLockCmd.MarkFlagsMutuallyExclusive(commonflags.ExpireAt, commonflags.Lifetime) }