make parser default unstrict for gcmd

This commit is contained in:
John
2020-01-08 19:30:56 +08:00
parent 9227139cf8
commit 81fd3d06bb
2 changed files with 8 additions and 2 deletions

View File

@ -49,7 +49,7 @@ func Parse(supportedOptions map[string]bool, strict ...bool) (*Parser, error) {
//
// The optional parameter <strict> specifies whether stops parsing and returns error if invalid option passed.
func ParseWithArgs(args []string, supportedOptions map[string]bool, strict ...bool) (*Parser, error) {
strictParsing := true
strictParsing := false
if len(strict) > 0 {
strictParsing = strict[0]
}
@ -95,7 +95,7 @@ func ParseWithArgs(args []string, supportedOptions map[string]bool, strict ...bo
}
i++
continue
} else {
} else if parser.strict {
return nil, errors.New(fmt.Sprintf(`invalid option '%s'`, args[i]))
}
}

View File

@ -15,6 +15,9 @@ import (
// ScanDir returns all sub-files with absolute paths of given <path>,
// It scans directory recursively if given parameter <recursive> is true.
//
// The pattern parameter <pattern> supports multiple file name patterns,
// using the ',' symbol to separate multiple patterns.
func ScanDir(path string, pattern string, recursive ...bool) ([]string, error) {
isRecursive := false
if len(recursive) > 0 {
@ -33,6 +36,9 @@ func ScanDir(path string, pattern string, recursive ...bool) ([]string, error) {
// ScanDirFile returns all sub-files with absolute paths of given <path>,
// It scans directory recursively if given parameter <recursive> is true.
//
// The pattern parameter <pattern> supports multiple file name patterns,
// using the ',' symbol to separate multiple patterns.
//
// Note that it returns only files, exclusive of directories.
func ScanDirFile(path string, pattern string, recursive ...bool) ([]string, error) {
isRecursive := false