mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-26 04:31:45 +00:00
passing a command by reference to 'processVars' instead of return types
This commit is contained in:
parent
024535de6f
commit
39a0a6d828
@ -9,21 +9,16 @@ import (
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
func processVars(isVariableType bool, args []string, configCmd string) ([]string, string) {
|
||||
var configArgs []string
|
||||
|
||||
for _, arg := range args {
|
||||
// If not replacable, append
|
||||
func processVars(cmd *util.Command, isVariableType bool) {
|
||||
// If not a variable type, return early as there's nothing to replace
|
||||
if !isVariableType {
|
||||
configArgs = append(configArgs, arg)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
// Replace specific "ProxySwitcher Argument" in command
|
||||
configCmd = strings.Replace(configCmd, "$PRSW_ARG", arg, 1)
|
||||
// Replace specific $PRSW_ARG in the command's Name with each argument
|
||||
for _, arg := range cmd.Arguments {
|
||||
cmd.Name = strings.Replace(cmd.Name, "$PRSW_ARG", arg, 1)
|
||||
}
|
||||
|
||||
return configArgs, configCmd
|
||||
}
|
||||
|
||||
func injectProxy(configArgs []string, configCmd, proxyServer string, variant *util.Variant) ([]string, string) {
|
||||
@ -68,8 +63,8 @@ func generateCommands(base string, variants []*util.Variant, proxyServer string)
|
||||
Arguments: append([]string{}, variant.Arguments...),
|
||||
}
|
||||
|
||||
configArgs, configCmd := processVars(isVariableType, cmd.Arguments, cmd.Name)
|
||||
configArgs, configCmd = injectProxy(configArgs, configCmd, proxyServer, variant)
|
||||
processVars(cmd, isVariableType)
|
||||
configArgs, configCmd := injectProxy(cmd.Arguments, cmd.Name, proxyServer, variant)
|
||||
|
||||
commands = append(commands, &util.Command{Name: configCmd, Arguments: configArgs})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user