cmd: refine

This commit is contained in:
Meo597
2026-10-12 22:20:45 +08:00
parent 6e6a592996
commit 3c74bcdf2a
2 changed files with 9 additions and 11 deletions
+4 -4
View File
@@ -10,11 +10,11 @@ import (
)
var cmdEncode = &base.Command{
UsageLine: "{{.Exec}} base64 encode [-gzip] [input-file | - | stdin:]",
UsageLine: "{{.Exec}} base64 encode [-gzip] <input-file | - | stdin:>",
Short: "Encode as Base64",
Long: fmt.Sprintf(`
Encode input-file as Base64 with the %s prefix.
Omit input-file or pass "-" or "stdin:" to read stdin.
Pass "-" or "stdin:" to read stdin.
Use -gzip to compress and output %s.
Examples:
@@ -31,13 +31,13 @@ func init() {
}
func executeEncode(cmd *base.Command, args []string) {
if len(args) > 1 {
if len(args) != 1 {
cmd.Usage()
}
var data []byte
var err error
if len(args) == 0 || args[0] == "-" || args[0] == "stdin:" {
if args[0] == "-" || args[0] == "stdin:" {
data, err = io.ReadAll(os.Stdin)
} else {
data, err = os.ReadFile(args[0])