2020-08-08 02:05:35 +00:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/stashapp/stash/pkg/plugin/common"
|
|
|
|
)
|
|
|
|
|
2022-04-25 05:55:05 +00:00
|
|
|
func toPluginArgs(args []*PluginArgInput) common.ArgsMap {
|
2020-08-08 02:05:35 +00:00
|
|
|
ret := make(common.ArgsMap)
|
|
|
|
for _, a := range args {
|
|
|
|
ret[a.Key] = toPluginArgValue(a.Value)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2022-04-25 05:55:05 +00:00
|
|
|
func toPluginArgValue(arg *PluginValueInput) common.PluginArgValue {
|
2020-08-08 02:05:35 +00:00
|
|
|
if arg == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case arg.Str != nil:
|
|
|
|
return common.PluginArgValue(*arg.Str)
|
|
|
|
case arg.I != nil:
|
|
|
|
return common.PluginArgValue(*arg.I)
|
|
|
|
case arg.B != nil:
|
|
|
|
return common.PluginArgValue(*arg.B)
|
|
|
|
case arg.F != nil:
|
|
|
|
return common.PluginArgValue(*arg.F)
|
|
|
|
case arg.O != nil:
|
|
|
|
return common.PluginArgValue(toPluginArgs(arg.O))
|
|
|
|
case arg.A != nil:
|
|
|
|
var ret []common.PluginArgValue
|
|
|
|
for _, v := range arg.A {
|
|
|
|
ret = append(ret, toPluginArgValue(v))
|
|
|
|
}
|
|
|
|
return common.PluginArgValue(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|