Merge pull request #901 from sosiska/patch-1
rewrite if-else to switch statement
This commit is contained in:
2 files changed
+9
-7
No files matched your search
@@ -146,13 +146,14 @@ func initAlpm() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if value, _, _ := cmdArgs.getArg("color"); value == "always" {
|
||||
switch value, _, _ := cmdArgs.getArg("color"); value {
|
||||
case "always":
|
||||
useColor = true
|
||||
} else if value == "auto" {
|
||||
case "auto":
|
||||
useColor = isTty()
|
||||
} else if value == "never" {
|
||||
case "never":
|
||||
useColor = false
|
||||
} else {
|
||||
default:
|
||||
useColor = pacmanConf.Color && isTty()
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -40,11 +40,12 @@ func (u upSlice) Less(i, j int) bool {
|
||||
|
||||
less := false
|
||||
found := syncDB.ForEach(func(db alpm.DB) error {
|
||||
if db.Name() == u[i].Repository {
|
||||
switch db.Name() {
|
||||
case u[i].Repository:
|
||||
less = true
|
||||
} else if db.Name() == u[j].Repository {
|
||||
case u[j].Repository:
|
||||
less = false
|
||||
} else {
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user