stash/pkg/plugin/convert.go
WithoutPants 7b5bd80515 Separate graphql API from rest of the system (#2503)
* Move graphql generated files to api
* Refactor identify options
* Remove models.StashBoxes
* Move ScraperSource to scraper package
* Rename field strategy enums
* Rename identify.TaskOptions to Options
2022-09-06 07:03:40 +00:00

41 lines
856 B
Go

package plugin
import (
"github.com/stashapp/stash/pkg/plugin/common"
)
func toPluginArgs(args []*PluginArgInput) common.ArgsMap {
ret := make(common.ArgsMap)
for _, a := range args {
ret[a.Key] = toPluginArgValue(a.Value)
}
return ret
}
func toPluginArgValue(arg *PluginValueInput) common.PluginArgValue {
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
}