mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
style(parser): simplify option creation
This commit is contained in:
parent
c159c06222
commit
de92f24ce5
@ -143,13 +143,7 @@ func install(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle, ignoreProvide
|
||||
}
|
||||
|
||||
if len(ignore) > 0 {
|
||||
if arguments.Options["ignore"] == nil {
|
||||
arguments.Options["ignore"] = &settings.Option{
|
||||
Args: ignore.ToSlice(),
|
||||
}
|
||||
} else {
|
||||
arguments.Options["ignore"].Add(ignore.ToSlice()...)
|
||||
}
|
||||
arguments.CreateOrAppendOption("ignore", ignore.ToSlice()...)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,16 @@ func (a *Arguments) String() string {
|
||||
return fmt.Sprintf("Op:%v Options:%+v Targets: %v", a.Op, a.Options, a.Targets)
|
||||
}
|
||||
|
||||
func (a *Arguments) CreateOrAppendOption(option string, values ...string) {
|
||||
if a.Options[option] == nil {
|
||||
a.Options[option] = &Option{
|
||||
Args: values,
|
||||
}
|
||||
} else {
|
||||
a.Options[option].Add(values...)
|
||||
}
|
||||
}
|
||||
|
||||
func MakeArguments() *Arguments {
|
||||
return &Arguments{
|
||||
"",
|
||||
@ -166,10 +176,7 @@ func (a *Arguments) addParam(option, arg string) error {
|
||||
return a.addOP(option)
|
||||
}
|
||||
|
||||
if a.Options[option] == nil {
|
||||
a.Options[option] = &Option{}
|
||||
}
|
||||
a.Options[option].Add(strings.Split(arg, ",")...)
|
||||
a.CreateOrAppendOption(option, strings.Split(arg, ",")...)
|
||||
|
||||
if isGlobal(option) {
|
||||
a.Options[option].Global = true
|
||||
|
Loading…
Reference in New Issue
Block a user