From 81fd3d06bb9a78e2b4364fd93f204ffeb52fc0e9 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 8 Jan 2020 19:30:56 +0800 Subject: [PATCH] make parser default unstrict for gcmd --- os/gcmd/gcmd_parser.go | 4 ++-- os/gfile/gfile_scan.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/os/gcmd/gcmd_parser.go b/os/gcmd/gcmd_parser.go index 33c249749..0ceba41c2 100644 --- a/os/gcmd/gcmd_parser.go +++ b/os/gcmd/gcmd_parser.go @@ -49,7 +49,7 @@ func Parse(supportedOptions map[string]bool, strict ...bool) (*Parser, error) { // // The optional parameter 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])) } } diff --git a/os/gfile/gfile_scan.go b/os/gfile/gfile_scan.go index adf247f96..3ab9879c2 100644 --- a/os/gfile/gfile_scan.go +++ b/os/gfile/gfile_scan.go @@ -15,6 +15,9 @@ import ( // ScanDir returns all sub-files with absolute paths of given , // It scans directory recursively if given parameter is true. +// +// The pattern parameter 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 , // It scans directory recursively if given parameter is true. // +// The pattern parameter 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