Skip to content

Commit 2d86ba2

Browse files
committed
Remove most global variables
1 parent fbd624c commit 2d86ba2

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

cmd/decode/main.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@ import (
1212
"github.com/sj14/multicode/decode"
1313
)
1414

15-
var (
16-
verbose bool
17-
byteDec bool
18-
hex bool
19-
base64 bool
20-
proto bool
21-
none bool
22-
)
15+
var verbose bool
2316

2417
func main() {
2518
// init flags
26-
flag.BoolVar(&byteDec, "byte", true, "use byte decoding")
27-
flag.BoolVar(&hex, "hex", true, "use hex decoding")
28-
flag.BoolVar(&base64, "base64", true, "use base64 decoding")
29-
flag.BoolVar(&proto, "proto", true, "use proto decoding")
30-
// flag.BoolVar(&none, "none", false, "disable all decodings") // TODO: not working yet
19+
var (
20+
byteDec = flag.Bool("byte", true, "use byte decoding")
21+
hex = flag.Bool("hex", true, "use hex decoding")
22+
base64 = flag.Bool("base64", true, "use base64 decoding")
23+
proto = flag.Bool("proto", true, "use proto decoding")
24+
// none := flag.Bool("none", false, "disable all decodings") // TODO: not working yet
25+
)
26+
3127
flag.BoolVar(&verbose, "v", false, "verbose output mode")
3228
flag.Parse()
3329

@@ -59,16 +55,16 @@ func main() {
5955
opts = append(opts, decode.WithoutAll())
6056

6157
// Enable specifified decodings.
62-
if byteDec {
58+
if *byteDec {
6359
opts = append(opts, decode.WithByte())
6460
}
65-
if hex {
61+
if *hex {
6662
opts = append(opts, decode.WithHex())
6763
}
68-
if base64 {
64+
if *base64 {
6965
opts = append(opts, decode.WithBase64())
7066
}
71-
if proto {
67+
if *proto {
7268
opts = append(opts, decode.WithProto())
7369
}
7470

0 commit comments

Comments
 (0)