AllPac/pkg/packagemanager/updater_utils.go
VetheonGames 132740b7a1 Major Update 6 (Pre-Release Binary 0.8)
Changes to main.go:
```
- make needed changes to remove the flag package
- refactor functions to use the preferred command syntax
```

changes to logger.go:
```
- make logger be quiet and stop outputting to STDOUT now that we are in user testing
```

changes to install.go:
```
- setup some extra logic in InstallPAckageSnap to install snaps in "classic confinement mode" if the user wishes
```

changes to updater_utils.go:
```
- create the file to contain some helper methods (namely one to update packages by name from a more central interface)
```

changes to cli_utils.go:
```
- create the file to contain some helper methods for the CLI (namely just a method to handle errors in the update process)
```
2024-01-07 17:30:30 -07:00

32 lines
820 B
Go

package packagemanager
import (
"fmt"
)
// UpdatePackageByName updates a specific package by its name
func UpdatePackageByName(packageName string) error {
pkgList, err := ReadPackageList()
if err != nil {
return fmt.Errorf("error reading package list: %v", err)
}
pkgInfo, exists := pkgList[packageName]
if !exists {
return fmt.Errorf("package %s not found in package list", packageName)
}
switch pkgInfo.Source {
case "pacman":
return UpdatePacmanPackages(packageName)
case "aur":
return UpdateAURPackages(packageName)
case "snap":
return UpdateSnapPackages(packageName)
case "flatpak":
return UpdateFlatpakPackages(packageName)
default:
return fmt.Errorf("unknown source for package %s", packageName)
}
}