Skip to content

Commit

Permalink
grep: make -l the default if no queries were provided
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgk committed Jul 17, 2022
1 parent 60edef8 commit b03c6de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 6 additions & 3 deletions grep.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@ func runGrep(args []string) int {
}
w := c.Walker(cflt)

// no need to actually grep if no queries were provided and only filenames were requested
// simple cache walk is enough and also will output results ordered by builder/origin/timestamp
if len(opts.Args()) == 0 && filenamesOnly {
// list only log filenames if no queries were provided
if len(opts.Args()) == 0 {
filenamesOnly = true

// no need to actually grep if no queries were provided and only filenames were requested
// simple cache walk is enough and also will output results ordered by builder/origin/timestamp
err = w.Walk(func(entry cache.Entry, err error) error {
if err != nil {
return err
Expand Down
5 changes: 1 addition & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import (
"github.com/dmgk/getopt"
)

const (
dateFormat = "2006-01-02"
)

var usageTmpl = template.Must(template.New("usage").Parse(`
usage: {{.progname}} [-hV] [-M mode] [-G colors] command [options]
Expand Down Expand Up @@ -43,6 +39,7 @@ var (
)

const (
dateFormat = "2006-01-02"
colorModeAuto = "auto"
colorModeAlways = "always"
colorModeNever = "never"
Expand Down

0 comments on commit b03c6de

Please sign in to comment.