Merge pull request #126 from Morganamilo/fix#122

Fixes #122 properly
This commit is contained in:
J Guerreiro 2018-01-31 17:50:23 +00:00 committed by GitHub
commit bd25a45829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 19 deletions

23
cmd.go
View File

@ -199,7 +199,6 @@ func initAlpm() (err error) {
func main() {
var status int
var err error
var changedConfig bool
err = cmdArgs.parseCommandLine()
if err != nil {
@ -222,7 +221,7 @@ func main() {
goto cleanup
}
changedConfig, err = handleCmd()
err = handleCmd()
if err != nil {
fmt.Println(err)
status = 1
@ -266,15 +265,17 @@ cleanup:
os.Exit(status)
}
func handleCmd() (changedConfig bool, err error) {
changedConfig = false
func handleCmd() (err error) {
for option := range cmdArgs.options {
changedConfig = changedConfig || handleConfig(option)
if handleConfig(option) {
cmdArgs.delArg(option)
}
}
for option := range cmdArgs.globals {
changedConfig = changedConfig || handleConfig(option)
if handleConfig(option) {
cmdArgs.delArg(option)
}
}
switch cmdArgs.op {
@ -315,7 +316,7 @@ func handleCmd() (changedConfig bool, err error) {
//my current plan is to have yay specific operations in its own operator
//e.g. yay -Y --gendb
//e.g yay -Yg
func handleConfig(option string) (changedConfig bool) {
func handleConfig(option string) bool {
switch option {
case "afterclean":
config.CleanAfter = true
@ -341,7 +342,7 @@ func handleConfig(option string) (changedConfig bool) {
config.TimeUpdate = false
case "topdown":
config.SortMode = TopDown
case "--bottomup":
case "bottomup":
config.SortMode = BottomUp
// case "help":
// usage()
@ -352,11 +353,11 @@ func handleConfig(option string) (changedConfig bool) {
case "noconfirm":
config.NoConfirm = true
default:
return
return false
}
changedConfig = true
return
return true
}
func handleVersion() {

View File

@ -61,6 +61,9 @@ var completionFile string
// Updated returns if database has been updated
var updated bool
// changedConfig holds whether or not the config has changed
var changedConfig bool
// YayConf holds the current config values for yay.
var config Configuration

View File

@ -447,10 +447,6 @@ func (parser *arguments) parseShortOption(arg string, param string) (usedNext bo
arg = arg[1:]
if isYayParam(arg) {
return
}
for k, _char := range arg {
char := string(_char)
@ -485,10 +481,6 @@ func (parser *arguments) parseLongOption(arg string, param string) (usedNext boo
arg = arg[2:]
if isYayParam(arg) {
return
}
if hasParam(arg) {
err = parser.addParam(arg, param)
usedNext = true