You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
633 B
Go
40 lines
633 B
Go
package operation
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/aziis98/cabret"
|
|
)
|
|
|
|
func init() {
|
|
registerType("categorize", &Categorize{})
|
|
}
|
|
|
|
type Categorize struct {
|
|
Key string
|
|
|
|
// Operation to be executed for each category
|
|
Operation cabret.Operation
|
|
}
|
|
|
|
func (op *Categorize) Load(config map[string]any) error {
|
|
{
|
|
v, ok := config["key"]
|
|
if !ok {
|
|
return fmt.Errorf(`missing "key" field`)
|
|
}
|
|
key, ok := v.(string)
|
|
if !ok {
|
|
return fmt.Errorf(`expected string but got "%v" of type %T`, v, v)
|
|
}
|
|
|
|
op.Key = key
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (op *Categorize) Process(content cabret.Content) (*cabret.Content, error) {
|
|
return nil, nil
|
|
}
|