mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-13 09:48:17 +03:00
cmd: refine
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user