From 43f1354e798373503c0ae4defd66e7bc3b52933b Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 24 Jan 2022 10:32:19 +0800 Subject: [PATCH] fix configuration support for package gcmd --- os/gcmd/gcmd_command_run.go | 2 +- os/gcmd/gcmd_parser.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/os/gcmd/gcmd_command_run.go b/os/gcmd/gcmd_command_run.go index 9669af81d..845900fa8 100644 --- a/os/gcmd/gcmd_command_run.go +++ b/os/gcmd/gcmd_command_run.go @@ -157,7 +157,7 @@ func (c *Command) reParse(ctx context.Context, parser *Parser) (*Parser, error) return nil, err } configMap := value.Map() - for optionName, _ := range parser.passedOptions { + for optionName, _ := range parser.supportedOptions { // The command line has the high priority. if parser.GetOpt(optionName) != nil { continue diff --git a/os/gcmd/gcmd_parser.go b/os/gcmd/gcmd_parser.go index ea59b7cbb..35aa4ae82 100644 --- a/os/gcmd/gcmd_parser.go +++ b/os/gcmd/gcmd_parser.go @@ -26,8 +26,8 @@ type Parser struct { strict bool // Whether stops parsing and returns error if invalid option passed. parsedArgs []string // As name described. parsedOptions map[string]string // As name described. - passedOptions map[string]bool // User passed supported options. - supportedOptions map[string]bool // Option [OptionName:WhetherNeedArgument]. + passedOptions map[string]bool // User passed supported options, like: map[string]bool{"name,n":true} + supportedOptions map[string]bool // Option [OptionName:WhetherNeedArgument], like: map[string]bool{"name":true, "n":true} commandFuncMap map[string]func() // Command function map for function handler. }