Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
42554a9298
commit
923f84722a
934 changed files with 3470 additions and 3451 deletions
47
cmd/frostfs-cli/internal/common/verbose.go
Normal file
47
cmd/frostfs-cli/internal/common/verbose.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||
"github.com/TrueCloudLab/frostfs-sdk-go/checksum"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// PrintVerbose prints to the stdout if the commonflags.Verbose flag is on.
|
||||
func PrintVerbose(format string, a ...interface{}) {
|
||||
if viper.GetBool(commonflags.Verbose) {
|
||||
fmt.Printf(format+"\n", a...)
|
||||
}
|
||||
}
|
||||
|
||||
// PrettyPrintUnixTime interprets s as unix timestamp and prints it as
|
||||
// a date. Is s is invalid, "malformed" is returned.
|
||||
func PrettyPrintUnixTime(s string) string {
|
||||
unixTime, err := strconv.ParseInt(s, 10, 64)
|
||||
if err != nil {
|
||||
return "malformed"
|
||||
}
|
||||
|
||||
timestamp := time.Unix(unixTime, 0)
|
||||
|
||||
return timestamp.String()
|
||||
}
|
||||
|
||||
// PrintChecksum prints checksum.
|
||||
func PrintChecksum(cmd *cobra.Command, name string, recv func() (checksum.Checksum, bool)) {
|
||||
var strVal string
|
||||
|
||||
cs, csSet := recv()
|
||||
if csSet {
|
||||
strVal = hex.EncodeToString(cs.Value())
|
||||
} else {
|
||||
strVal = "<empty>"
|
||||
}
|
||||
|
||||
cmd.Printf("%s: %s\n", name, strVal)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue