fix(parser): fix ignores getting... ignored

This commit is contained in:
jguer 2020-07-26 23:00:28 +02:00
parent cd8fb7143c
commit 7dd5d7e13e
No known key found for this signature in database
GPG key ID: 6D6CC9BEA8556B35
3 changed files with 17 additions and 14 deletions

View file

@ -142,19 +142,13 @@ func install(cmdArgs *settings.Arguments, alpmHandle *alpm.Handle, ignoreProvide
cmdArgs.AddTarget("aur/" + up) cmdArgs.AddTarget("aur/" + up)
} }
value, _, exists := cmdArgs.GetArg("ignore")
if len(ignore) > 0 { if len(ignore) > 0 {
ignoreStr := strings.Join(ignore.ToSlice(), ",")
if exists {
ignoreStr += "," + value
}
if arguments.Options["ignore"] == nil { if arguments.Options["ignore"] == nil {
arguments.Options["ignore"] = &settings.Option{ arguments.Options["ignore"] = &settings.Option{
Args: []string{ignoreStr}, Args: ignore.ToSlice(),
} }
} else { } else {
arguments.Options["ignore"].Add(ignoreStr) arguments.Options["ignore"].Add(ignore.ToSlice()...)
} }
} }
} }

View file

@ -93,8 +93,8 @@ func initAlpm(cmdArgs *settings.Arguments, pacmanConfigPath string) (*alpm.Handl
pacmanConf.Architecture = value pacmanConf.Architecture = value
} }
if value, _, exists := cmdArgs.GetArg("ignore"); exists { if ignoreArray := cmdArgs.GetArgs("ignore"); ignoreArray != nil {
pacmanConf.IgnorePkg = append(pacmanConf.IgnorePkg, strings.Split(value, ",")...) pacmanConf.IgnorePkg = append(pacmanConf.IgnorePkg, ignoreArray...)
} }
if value, _, exists := cmdArgs.GetArg("ignoregroup"); exists { if value, _, exists := cmdArgs.GetArg("ignoregroup"); exists {

View file

@ -17,12 +17,12 @@ type Option struct {
Args []string Args []string
} }
func (o *Option) Add(arg string) { func (o *Option) Add(args ...string) {
if o.Args == nil { if o.Args == nil {
o.Args = []string{arg} o.Args = args
return return
} }
o.Args = append(o.Args, arg) o.Args = append(o.Args, args...)
} }
func (o *Option) First() string { func (o *Option) First() string {
@ -169,7 +169,7 @@ func (a *Arguments) addParam(option, arg string) error {
if a.Options[option] == nil { if a.Options[option] == nil {
a.Options[option] = &Option{} a.Options[option] = &Option{}
} }
a.Options[option].Add(arg) a.Options[option].Add(strings.Split(arg, ",")...)
if isGlobal(option) { if isGlobal(option) {
a.Options[option].Global = true a.Options[option].Global = true
@ -208,6 +208,15 @@ func (a *Arguments) GetArg(options ...string) (arg string, double, exists bool)
return arg, false, false return arg, false, false
} }
func (a *Arguments) GetArgs(option string) (args []string) {
value, exists := a.Options[option]
if exists {
return value.Args
}
return nil
}
func (a *Arguments) AddTarget(targets ...string) { func (a *Arguments) AddTarget(targets ...string) {
a.Targets = append(a.Targets, targets...) a.Targets = append(a.Targets, targets...)
} }