Skip to content

Commit

Permalink
Fixed to return correct error
Browse files Browse the repository at this point in the history
Fixed to return correct error if filePath.Glob does not match.
  • Loading branch information
noborus committed Jan 9, 2024
1 parent 0bc88ba commit 9409155
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,21 @@ func Completion(cmd *cobra.Command, arg string) error {
return ErrCompletion
}

// argsToFiles returns the file name from the argument.
func argsToFiles(args []string) []string {
var files []string
for _, arg := range args {
argFiles, err := filepath.Glob(arg)
if err != nil {
fmt.Fprintln(os.Stderr, err)
continue
}
files = append(files, argFiles...)
}
// If filePath.Glob does not match,
// return argument to return correct error
if len(files) == 0 {
return args
}
return files
}

Expand Down

0 comments on commit 9409155

Please sign in to comment.