Skip to content

Commit

Permalink
Fix default value for --pattern
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Shishkin <me@teran.ru>
  • Loading branch information
teran committed Nov 30, 2018
1 parent 1214ae3 commit 5d671bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 9 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"github.com/cosiner/flag"
)

const (
defaultRawFilePattern = ".(3fr|ari|arw|bay|crw|cr2|cr3|cap|data|dcs|dcr|drf|eip|erf|fff|gpr|iiq|k25|kdc|mdc|mef|mos|mrw|nef|nrw|obm|orf|pef|ptx|pxn|r3d|raf|raw|rwl|rw2|rwz|sr2|srf|srw|x3f)$"
)

type config struct {
Concurrency int `names:"--concurrency, -c" usage:"Amount of routines to spawn at the same time for checksum verification"`
Complete bool `names:"--complete" usage:"Completion for shell"`
Expand Down Expand Up @@ -37,6 +41,10 @@ func newConfig() *config {
c.Concurrency = runtime.NumCPU()
}

if c.Pattern == "" {
c.Pattern = defaultRawFilePattern
}

return &c
}

Expand Down Expand Up @@ -64,7 +72,7 @@ func (c *config) Metadata() map[string]flag.Flag {
Desc: fmt.Sprintf("Default value is %d for your system", runtime.NumCPU()),
},
"--pattern": {
Desc: fmt.Sprintf("Default is `%s`", rawFilePattern),
Desc: fmt.Sprintf("Default is `%s`", defaultRawFilePattern),
},
}
}
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ var (
// Version - variable to store current commit,tag,whatever
Version = "No version specified(probably trunk build)"

db *database.Database
filePattern *regexp.Regexp
rawFilePattern = ".(3fr|ari|arw|bay|crw|cr2|cr3|cap|data|dcs|dcr|drf|eip|erf|fff|gpr|iiq|k25|kdc|mdc|mef|mos|mrw|nef|nrw|obm|orf|pef|ptx|pxn|r3d|raf|raw|rwl|rw2|rwz|sr2|srf|srw|x3f)$"
db *database.Database
filePattern *regexp.Regexp

cntAdded uint64
cntFailed uint64
Expand Down

0 comments on commit 5d671bd

Please sign in to comment.