Skip to content

Commit

Permalink
cli: add a default range length for object hash to cli help
Browse files Browse the repository at this point in the history
Also, print a verbose message if the default range length is used.

Closes #1693.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
  • Loading branch information
End-rey committed Oct 29, 2024
1 parent 1b2a229 commit abcfe94
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/neofs-cli/modules/object/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
Expand Down Expand Up @@ -42,7 +43,7 @@ func initObjectHashCmd() {
flags.String(commonflags.OIDFlag, "", commonflags.OIDFlagUsage)
_ = objectHashCmd.MarkFlagRequired(commonflags.OIDFlag)

flags.String("range", "", "Range to take hash from in the form offset1:length1,...")
flags.String("range", "", "Range to take hash from in the form offset1:length1,... Full object payload length if not specified")

Check warning on line 46 in cmd/neofs-cli/modules/object/hash.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/hash.go#L46

Added line #L46 was not covered by tests
flags.String("type", hashSha256, "Hash type. Either 'sha256' or 'tz'")
flags.String(getRangeHashSaltFlag, "", "Salt in hex format")
}
Expand Down Expand Up @@ -87,6 +88,7 @@ func getObjectHash(cmd *cobra.Command, _ []string) error {
tz := typ == hashTz
fullHash := len(ranges) == 0
if fullHash {
common.PrintVerbose(cmd, "Get the hash of the full object payload.")

Check warning on line 91 in cmd/neofs-cli/modules/object/hash.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/object/hash.go#L91

Added line #L91 was not covered by tests
var headPrm internalclient.HeadObjectPrm
headPrm.SetPrivateKey(*pk)
headPrm.SetClient(cli)
Expand Down

0 comments on commit abcfe94

Please sign in to comment.