-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The '-c' flag can be used multiple times (#1985)
Change '-c' flag to load and merge all config files given on command line via '-c' flag.
- Loading branch information
Showing
4 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cfgfile | ||
|
||
import ( | ||
"flag" | ||
"strings" | ||
) | ||
|
||
type argList struct { | ||
list []string | ||
isDefault bool | ||
} | ||
|
||
func flagArgList(name string, def string, usage string) *argList { | ||
l := &argList{ | ||
list: []string{def}, | ||
isDefault: true, | ||
} | ||
flag.Var(l, name, usage) | ||
return l | ||
} | ||
|
||
func (l *argList) SetDefault(v string) { | ||
l.list = []string{v} | ||
l.isDefault = true | ||
} | ||
|
||
func (l *argList) String() string { | ||
return strings.Join(l.list, ", ") | ||
} | ||
|
||
func (l *argList) Set(v string) error { | ||
if l.isDefault { | ||
l.list = []string{v} | ||
} else { | ||
l.list = append(l.list, v) | ||
} | ||
l.isDefault = false | ||
return nil | ||
} | ||
|
||
func (l *argList) Get() interface{} { | ||
return l.list | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters