[#1233] neofs-cli: Do not print info if output format is strict

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-03-14 16:39:49 +03:00 committed by Alex Vanin
parent 5eef0f46c5
commit 800d01e28c

View file

@ -559,15 +559,17 @@ func getObject(cmd *cobra.Command, _ []string) {
exitOnErr(cmd, errf("rpc error: %w", err))
}
hdrFile := cmd.Flag("header").Value.String()
if filename != "" {
if p != nil {
p.Finish()
}
cmd.Printf("[%s] Object successfully saved\n", filename)
if hdrFile != "" || !strictOutput(cmd) {
cmd.Printf("[%s] Object successfully saved\n", filename)
}
}
// Print header only if file is not streamed to stdout.
hdrFile := cmd.Flag("header").Value.String()
if filename != "" || hdrFile != "" {
err = saveAndPrintHeader(cmd, res.Header(), hdrFile)
exitOnErr(cmd, err)
@ -1002,6 +1004,12 @@ func printSplitHeader(cmd *cobra.Command, obj *object.Object) error {
return nil
}
func strictOutput(cmd *cobra.Command) bool {
toJSON, _ := cmd.Flags().GetBool("json")
toProto, _ := cmd.Flags().GetBool("proto")
return toJSON || toProto
}
func marshalHeader(cmd *cobra.Command, hdr *object.Object) ([]byte, error) {
toJSON, _ := cmd.Flags().GetBool("json")
toProto, _ := cmd.Flags().GetBool("proto")