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

View File

@ -142,8 +142,14 @@ func main() {
if useRoot { if useRoot {
cmdArr = append(cmdArr, rootCommand) cmdArr = append(cmdArr, rootCommand)
} }
// Create slice with all commands and arguments for the package manager // 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]) cmdArr = append(cmdArr, config.ActiveManager, similarTo[0])
}
// If greater than 2 arguments, append them to cmdArr // If greater than 2 arguments, append them to cmdArr
if len(args) >= 2 { if len(args) >= 2 {
cmdArr = append(cmdArr, strings.Join(args[1:], " ")) cmdArr = append(cmdArr, strings.Join(args[1:], " "))

View File

@ -14,6 +14,10 @@ rootCommand = "sudo"
upgrade = "upgrade" upgrade = "upgrade"
download = "download" download = "download"
clean = "clean" 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] [managers.apt.shortcuts]
arm = "autoremove" arm = "autoremove"
@ -39,6 +43,10 @@ rootCommand = "sudo"
show = "show" show = "show"
list = "search '~i'" list = "search '~i'"
changelog = "changelog" 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] [managers.brew]
useRoot = false useRoot = false