Skip to content

Commit

Permalink
Add first only flag
Browse files Browse the repository at this point in the history
  • Loading branch information
WTFox committed May 27, 2021
1 parent 5cd4a4a commit 83a45a0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/jf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

const flagParentPaths = "parent-paths"
const flagFirstOnly = "first-only"

func main() {
app := &cli.App{
Expand All @@ -28,6 +29,11 @@ func main() {
Usage: "Renders the parent paths only",
Aliases: []string{"p"},
},
&cli.BoolFlag{
Name: flagFirstOnly,
Usage: "Returns the first occurrence only",
Aliases: []string{"f"},
},
},
}

Expand Down Expand Up @@ -66,6 +72,9 @@ func doSearch(c *cli.Context) error {
} else {
fmt.Println(occurrence)
}
if c.Bool(flagFirstOnly) {
return nil
}
}

return nil
Expand Down

0 comments on commit 83a45a0

Please sign in to comment.