Skip to content

Commit 26ab214

Browse files
committed
show version flag
1 parent 1d29e4b commit 26ab214

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/sif/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import (
99
"github.com/fatih/color"
1010
)
1111

12+
const version = "0.0.1"
13+
1214
var (
1315
opt sif.Options
1416
printOnlyFilenames bool
17+
showVersion bool
1518
)
1619

1720
func init() {
@@ -25,12 +28,18 @@ func init() {
2528
}
2629
flag.BoolVar(&opt.CaseInsensitive, "i", false, "Ignore case distinctions in PATTERN")
2730
flag.BoolVar(&printOnlyFilenames, "l", false, "Only print filenames containing matches")
31+
flag.BoolVar(&showVersion, "v", false, "Display version")
2832
}
2933

3034
func main() {
3135
flag.Parse()
3236
args := flag.Args()
3337

38+
if showVersion {
39+
fmt.Printf("%s: %s", os.Args[0], version)
40+
os.Exit(0)
41+
}
42+
3443
dirs := make([]string, 0)
3544
switch flag.NArg() {
3645
case 0: // without pattern

0 commit comments

Comments
 (0)