Skip to content

Commit ced80de

Browse files
committed
Merge pull request astaxie#23 from micanzhang/master
add version flag
2 parents edf2967 + c7317f7 commit ced80de

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

bat.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
const version = "0.0.2"
3737

3838
var (
39+
ver bool
3940
form bool
4041
pretty bool
4142
download bool
@@ -55,6 +56,7 @@ var (
5556
)
5657

5758
func init() {
59+
flag.BoolVar(&ver, "v", false, "Print Version Number")
5860
flag.BoolVar(&pretty, "pretty", true, "Print Json Pretty Fomat")
5961
flag.BoolVar(&pretty, "p", true, "Print Json Pretty Fomat")
6062
flag.StringVar(&printV, "print", "A", "Print request and response")
@@ -82,6 +84,10 @@ func main() {
8284
if len(args) > 0 {
8385
args = filter(args)
8486
}
87+
if ver {
88+
fmt.Println("Version:", version)
89+
os.Exit(2)
90+
}
8591
if printV != "A" && printV != "B" {
8692
defaultSetting.DumpBody = false
8793
}
@@ -313,6 +319,7 @@ flags:
313319
"B" request body
314320
"h" response headers
315321
"b" response body
322+
-v Show Version Number
316323
METHOD:
317324
bat defaults to either GET (if there is no request data) or POST (with request data).
318325

0 commit comments

Comments
 (0)