refactor: hide --output flags that don't work (#17188)

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
zakir-code 2023-07-30 07:53:27 +08:00 committed by GitHub
parent 33051ceb39
commit 0b5e7ed0af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 16 deletions

View File

@ -48,6 +48,7 @@ func GetDecodeCommand() *cobra.Command {
cmd.Flags().BoolP(flagHex, "x", false, "Treat input as hexadecimal instead of base64")
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput) // decoding makes sense to output only json
return cmd
}

View File

@ -42,6 +42,7 @@ If you supply a dash (-) argument in place of an input filename, the command rea
}
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput) // encoding makes sense to output only json
return cmd
}

View File

@ -61,6 +61,7 @@ The SIGN_MODE_DIRECT sign mode is not supported.'
cmd.Flags().Bool(flagSigOnly, false, "Print only the generated signature, then exit")
cmd.Flags().String(flags.FlagOutputDocument, "", "The document is written to the given file instead of STDOUT")
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput)
return cmd
}
@ -180,27 +181,15 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) {
return err
}
outputDoc, _ := cmd.Flags().GetString(flags.FlagOutputDocument)
if outputDoc == "" {
cmd.Printf("%s\n", json)
return nil
}
fp, err := os.OpenFile(outputDoc, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644)
closeFunc, err := setOutputFile(cmd)
if err != nil {
return err
}
defer func() {
err2 := fp.Close()
if err == nil {
err = err2
}
}()
defer closeFunc()
err = clientCtx.PrintBytes(json)
return err
cmd.Printf("%s\n", json)
return nil
}
}
@ -235,6 +224,7 @@ The SIGN_MODE_DIRECT sign mode is not supported.'
)
cmd.Flags().String(flags.FlagOutputDocument, "", "The document is written to the given file instead of STDOUT")
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput) // signing makes sense to output only json
return cmd
}

View File

@ -216,6 +216,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o
cmd.Flags().String(flags.FlagOutputDocument, "", "Write the genesis transaction JSON document to the given file instead of the default location")
cmd.Flags().AddFlagSet(fsCreateValidator)
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput) // signing makes sense to output only json
return cmd
}