Rework variables to not be commands...
This commit is contained in:
21
main.go
21
main.go
@@ -190,29 +190,16 @@ func runModifier(args []string, cmd *cobra.Command) {
|
||||
// Load all commands
|
||||
mainLogger.Debug("Loading commands from arguments")
|
||||
mainLogger.Trace("Arguments: %v", args)
|
||||
commands, err := utils.LoadCommands(args)
|
||||
commands, modifiers, err := utils.LoadCommands(args)
|
||||
if err != nil || len(commands) == 0 {
|
||||
mainLogger.Error("Failed to load commands: %v", err)
|
||||
cmd.Usage()
|
||||
return
|
||||
}
|
||||
// Collect global modifiers from special entries and filter them out
|
||||
vars := map[string]interface{}{}
|
||||
filtered := make([]utils.ModifyCommand, 0, len(commands))
|
||||
for _, c := range commands {
|
||||
if len(c.Modifiers) > 0 && c.Name == "" && c.Regex == "" && len(c.Regexes) == 0 && c.Lua == "" && len(c.Files) == 0 {
|
||||
for k, v := range c.Modifiers {
|
||||
vars[k] = v
|
||||
}
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, c)
|
||||
if len(modifiers) > 0 {
|
||||
mainLogger.Info("Loaded %d global modifiers", len(modifiers))
|
||||
processor.SetVariables(modifiers)
|
||||
}
|
||||
if len(vars) > 0 {
|
||||
mainLogger.Info("Loaded %d global modifiers", len(vars))
|
||||
processor.SetVariables(vars)
|
||||
}
|
||||
commands = filtered
|
||||
mainLogger.Info("Loaded %d commands", len(commands))
|
||||
|
||||
if filterFlag != "" {
|
||||
|
||||
Reference in New Issue
Block a user