Implement running non-manager commands in config

This commit is contained in:
Elara 2021-01-09 01:14:40 -08:00
parent 661242582e
commit 98dcb1532e
2 changed files with 16 additions and 2 deletions

10
main.go
View File

@ -142,8 +142,14 @@ func main() {
if useRoot {
cmdArr = append(cmdArr, rootCommand)
}
// Create slice with all commands and arguments for the package manager
cmdArr = append(cmdArr, config.ActiveManager, similarTo[0])
// If command to be run has a prefix of "cmd:"
if strings.HasPrefix(similarTo[0], "cmd:") {
// Append the command to the slice without the prefix
cmdArr = append(cmdArr, strings.TrimPrefix(similarTo[0], "cmd:"))
} else {
// Otherwise, append all commands and arguments for the package manager to slice
cmdArr = append(cmdArr, config.ActiveManager, similarTo[0])
}
// If greater than 2 arguments, append them to cmdArr
if len(args) >= 2 {
cmdArr = append(cmdArr, strings.Join(args[1:], " "))

View File

@ -14,6 +14,10 @@ rootCommand = "sudo"
upgrade = "upgrade"
download = "download"
clean = "clean"
file-refresh = "cmd:apt-file update"
file-search = "cmd:apt-file search"
add-key = "cmd:apt-key add"
add-repo = "cmd:add-apt-repository"
[managers.apt.shortcuts]
arm = "autoremove"
@ -39,6 +43,10 @@ rootCommand = "sudo"
show = "show"
list = "search '~i'"
changelog = "changelog"
file-refresh = "cmd:apt-file update"
file-search = "cmd:apt-file search"
add-key = "cmd:apt-key add"
add-repo = "cmd:add-apt-repository"
[managers.brew]
useRoot = false