mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
make parser default unstrict for gcmd
This commit is contained in:
@ -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]))
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user