diff --git a/cmd/neofs-cli/modules/object.go b/cmd/neofs-cli/modules/object.go index 53a647cae..12d5cd030 100644 --- a/cmd/neofs-cli/modules/object.go +++ b/cmd/neofs-cli/modules/object.go @@ -80,6 +80,8 @@ const ( rangeSep = ":" ) +const searchOIDFlag = "oid" + func init() { rootCmd.AddCommand(objectCmd) objectCmd.PersistentFlags().String("bearer", "", "File with signed JSON or binary encoded bearer token") @@ -114,6 +116,7 @@ func init() { objectSearchCmd.Flags().String("filters", "", "Filters in the form hdrName=value,...") objectSearchCmd.Flags().Bool("root", false, "Search for user objects") objectSearchCmd.Flags().Bool("phy", false, "Search physically stored objects") + objectSearchCmd.Flags().String(searchOIDFlag, "", "Search object by identifier") objectCmd.AddCommand(objectHeadCmd) objectHeadCmd.Flags().String("file", "", "File to write header to. Default: stdout.") @@ -460,6 +463,16 @@ func parseSearchFilters(cmd *cobra.Command) (object.SearchFilters, error) { fs.AddPhyFilter() } + oid, _ := cmd.Flags().GetString(searchOIDFlag) + if oid != "" { + id := object.NewID() + if err := id.Parse(oid); err != nil { + return nil, err + } + + fs.AddObjectIDFilter(object.MatchStringEqual, id) + } + return fs, nil }