File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ Application Options:
2424 --path= use files in this path
2525 --path-pattern= file pattern (* for wildcard, only basename of file)
2626 --path-regex= file pattern (regex, full path)
27+ --ignore-empty ignore empty file list, otherwise this will result in an error
2728 -v, --verbose verbose mode
2829 --dry-run dry run mode
2930 -V, --version show version and exit
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ var opts struct {
3030 Path string ` long:"path" description:"use files in this path"`
3131 PathPattern string ` long:"path-pattern" description:"file pattern (* for wildcard, only basename of file)"`
3232 PathRegex string ` long:"path-regex" description:"file pattern (regex, full path)"`
33+ IgnoreEmpty bool ` long:"ignore-empty" description:"ignore empty file list, otherwise this will result in an error"`
3334 Verbose bool `short:"v" long:"verbose" description:"verbose mode"`
3435 DryRun bool ` long:"dry-run" description:"dry run mode"`
3536 ShowVersion bool `short:"V" long:"version" description:"show version and exit"`
@@ -272,11 +273,18 @@ func main() {
272273
273274 // check if there is at least one file to process
274275 if (len (args ) == 0 ) {
275- err := errors .New ("No files specified" )
276- logError (err )
277- fmt .Println ()
278- argparser .WriteHelp (os .Stdout )
279- os .Exit (1 )
276+ if (opts .IgnoreEmpty ) {
277+ // no files found, but we should ignore empty filelist
278+ logMessage ("No files found, requsted to ignore this" )
279+ os .Exit (0 )
280+ } else {
281+ // no files found, print error and exit with error code
282+ err := errors .New ("No files specified" )
283+ logError (err )
284+ fmt .Println ()
285+ argparser .WriteHelp (os .Stdout )
286+ os .Exit (1 )
287+ }
280288 }
281289
282290 // build regex search term
You can’t perform that action at this time.
0 commit comments