Fix incorrect spacing of commands

This commit is contained in:
ferrreo 2023-01-18 17:52:29 +00:00
parent abcc91ecb9
commit bb345ba8a2
7 changed files with 13 additions and 11 deletions

2
.gitignore vendored
View File

@ -14,3 +14,5 @@
# Dependency directories (remove the comment below to include it) # Dependency directories (remove the comment below to include it)
# vendor/ # vendor/
.idea .idea
pikman

View File

@ -1,6 +1,6 @@
package alpine package alpine
var PackageManager = "apx " var PackageManager = "apx"
var Commands = map[string]string{ var Commands = map[string]string{
"autoremove": "--apk autoremove", "autoremove": "--apk autoremove",

View File

@ -1,6 +1,6 @@
package arch package arch
var PackageManager = "apx " var PackageManager = "apx"
var Commands = map[string]string{ var Commands = map[string]string{
"autoremove": "--aur autoremove", "autoremove": "--aur autoremove",

View File

@ -1,6 +1,6 @@
package fedora package fedora
var PackageManager = "apx " var PackageManager = "apx"
var Commands = map[string]string{ var Commands = map[string]string{
"autoremove": "--dnf autoremove", "autoremove": "--dnf autoremove",

View File

@ -1,6 +1,6 @@
package flatpak package flatpak
var PackageManager = "flatpak " var PackageManager = "flatpak"
var Commands = map[string]string{ var Commands = map[string]string{
"install": "install", "install": "install",

10
main.go
View File

@ -247,35 +247,35 @@ func getCommand(command string, osType OSType, containerName string, packageName
case Arch: case Arch:
cmd, ok := arch.Commands[command] cmd, ok := arch.Commands[command]
if ok { if ok {
return arch.PackageManager + cmd + containerName + strings.Join(packageName, " "), nil return fmt.Sprintf("%s %s %s %s", arch.PackageManager, cmd, containerName, strings.Join(packageName, " ")), nil
} else { } else {
return "", fmt.Errorf("%s: is not a valid command for Arch", command) return "", fmt.Errorf("%s: is not a valid command for Arch", command)
} }
case Fedora: case Fedora:
cmd, ok := fedora.Commands[command] cmd, ok := fedora.Commands[command]
if ok { if ok {
return fedora.PackageManager + cmd + containerName + strings.Join(packageName, " "), nil return fmt.Sprintf("%s %s %s %s", fedora.PackageManager, cmd, containerName, strings.Join(packageName, " ")), nil
} else { } else {
return "", fmt.Errorf("%s: is not a valid command for Fedora", command) return "", fmt.Errorf("%s: is not a valid command for Fedora", command)
} }
case Flatpak: case Flatpak:
cmd, ok := flatpak.Commands[command] cmd, ok := flatpak.Commands[command]
if ok { if ok {
return flatpak.PackageManager + cmd + strings.Join(packageName, " "), nil return fmt.Sprintf("%s %s %s", flatpak.PackageManager, cmd, strings.Join(packageName, " ")), nil
} else { } else {
return "", fmt.Errorf("%s: is not a valid command for Flatpak", command) return "", fmt.Errorf("%s: is not a valid command for Flatpak", command)
} }
case Alpine: case Alpine:
cmd, ok := alpine.Commands[command] cmd, ok := alpine.Commands[command]
if ok { if ok {
return alpine.PackageManager + cmd + containerName + strings.Join(packageName, " "), nil return fmt.Sprintf("%s %s %s %s", alpine.PackageManager, cmd, containerName, strings.Join(packageName, " ")), nil
} else { } else {
return "", fmt.Errorf("%s: is not a valid command for Alpine", command) return "", fmt.Errorf("%s: is not a valid command for Alpine", command)
} }
case Ubuntu: case Ubuntu:
cmd, ok := ubuntu.Commands[command] cmd, ok := ubuntu.Commands[command]
if ok { if ok {
return ubuntu.PackageManager + cmd + strings.Join(packageName, " "), nil return fmt.Sprintf("%s %s %s", ubuntu.PackageManager, cmd, strings.Join(packageName, " ")), nil
} else { } else {
return "", fmt.Errorf("%s: is not a valid command for Ubuntu", command) return "", fmt.Errorf("%s: is not a valid command for Ubuntu", command)
} }

View File

@ -1,6 +1,6 @@
package ubuntu package ubuntu
var PackageManager = "sudo -S apt " var PackageManager = "sudo -S apt"
var Commands = map[string]string{ var Commands = map[string]string{
"autoremove": "autoremove", "autoremove": "autoremove",