You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ neofs-cli object put <required_flags> --attributes RunNumber=184 --attributes FilePath=184.zip ContentType=application/zip
command executed successfully. Resulting object was created withFilePath attribute and withoutContentType and Number ones.
Overview
currently object put command accepts single flag attributes of string type to specify list of user-defined object attributes:
$ neofs-cli object put -h
--attributes string User attributes in form of Key1=Value1,Key2=Value2
with next behavior:
if multiple flags specified (see example), only the latest one will enter the object
if value contains spaces, all data starting from the 1st space is ignored
Proposal
1. Change type to repeated strings
it may be incovenient to specify multiple attributes in single comma-separated flag without spaces (imagine 5+ elements).
we can support the ability to repeat the flag, while still maintaining the comma-separated format. It'll be easy todo via Cobra's (NeoFS CLI engine) https://pkg.go.dev/github.com/spf13/pflag#StringSlice flag type. In example above, user could specify
and all 3 attributes would be accepted. It may be useful when, for example, some attributes are related like RunNumber and FilePath while ContentType is still independent.
With this approach, the name --attributes becomes redundant and can be replaced by --attribute. To me, this alternative a bit weaker then the slice one, but also concise.
2. Strict positional arguments
as we can see in the original example, space-separated ContentType=application/zip input is ignored. It happens cuz Cobra interprets this input part as one of the command's positional arguments, and object put command just ignores them. From the user pov, it happens unexpectedly and the input quietly disappears inside.
as a solution, we can start to strictly verify positional input of the command (worth to do for all commands globally), so user could see invalid input message and write his command more precisely.
imo strictness is always much better than freedom bordering on uncertainty
The `object put` command previously could only retrieve the last
`--attributes` parameter if multiple such parameters were provided. Now,
the `object put` command correctly parses all `--attributes` values,
whether they are provided as comma-separated or single values.
Closes#2427.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
The `object put` command previously could only retrieve the last
`--attributes` parameter if multiple such parameters were provided. Now,
the `object put` command correctly parses all `--attributes` values,
whether they are provided as comma-separated or single values.
Closes#2427.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
Context
Originally posted by @vvarg229
command executed successfully. Resulting object was created with
FilePath
attribute and withoutContentType
andNumber
ones.Overview
currently
object put
command accepts single flagattributes
of string type to specify list of user-defined object attributes:with next behavior:
Proposal
1. Change type to repeated strings
it may be incovenient to specify multiple attributes in single comma-separated flag without spaces (imagine 5+ elements).
we can support the ability to repeat the flag, while still maintaining the comma-separated format. It'll be easy todo via Cobra's (NeoFS CLI engine) https://pkg.go.dev/github.com/spf13/pflag#StringSlice flag type. In example above, user could specify
and all 3 attributes would be accepted. It may be useful when, for example, some attributes are related like
RunNumber
andFilePath
whileContentType
is still independent.as an alternative, we can support multiple flags with single attributes (w/o comma-splitting within single value). To do this, Cobra provides https://pkg.go.dev/github.com/spf13/pflag#StringArray flag type.
With this approach, the name
--attributes
becomes redundant and can be replaced by--attribute
. To me, this alternative a bit weaker then the slice one, but also concise.2. Strict positional arguments
as we can see in the original example, space-separated
ContentType=application/zip
input is ignored. It happens cuz Cobra interprets this input part as one of the command's positional arguments, andobject put
command just ignores them. From the user pov, it happens unexpectedly and the input quietly disappears inside.as a solution, we can start to strictly verify positional input of the command (worth to do for all commands globally), so user could see
invalid input
message and write his command more precisely.imo strictness is always much better than freedom bordering on uncertainty
AFAIK, similar improvement were added in NeoGo project, correct me pls @AnnaShaleva @roman-khimov
The text was updated successfully, but these errors were encountered: