/
println.cf.go
97 lines (85 loc) · 2.41 KB
/
println.cf.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Code generated by Conflow. DO NOT EDIT.
package blocks
import (
"fmt"
"github.com/conflowio/conflow/src/conflow"
"github.com/conflowio/conflow/src/conflow/annotations"
"github.com/conflowio/conflow/src/schema"
)
func init() {
schema.Register(&schema.Object{
Metadata: schema.Metadata{
Annotations: map[string]string{
annotations.Type: "task",
},
Description: "It will write a string followed by a new line to the standard output",
ID: "github.com/conflowio/conflow/src/blocks.Println",
},
Properties: map[string]schema.Schema{
"id": &schema.String{
Metadata: schema.Metadata{
Annotations: map[string]string{
annotations.ID: "true",
},
ReadOnly: true,
},
Format: "conflow.ID",
},
"value": &schema.Untyped{
Metadata: schema.Metadata{
Annotations: map[string]string{
annotations.Value: "true",
},
},
},
},
Required: []string{"value"},
})
}
// PrintlnInterpreter is the Conflow interpreter for the Println block
type PrintlnInterpreter struct {
}
func (i PrintlnInterpreter) Schema() schema.Schema {
s, _ := schema.Get("github.com/conflowio/conflow/src/blocks.Println")
return s
}
// Create creates a new Println block
func (i PrintlnInterpreter) CreateBlock(id conflow.ID, blockCtx *conflow.BlockContext) conflow.Block {
b := &Println{}
b.id = id
b.stdout = blockCtx.Stdout()
return b
}
// ValueParamName returns the name of the parameter marked as value field, if there is one set
func (i PrintlnInterpreter) ValueParamName() conflow.ID {
return "value"
}
// ParseContext returns with the parse context for the block
func (i PrintlnInterpreter) ParseContext(ctx *conflow.ParseContext) *conflow.ParseContext {
var nilBlock *Println
if b, ok := conflow.Block(nilBlock).(conflow.ParseContextOverrider); ok {
return ctx.New(b.ParseContextOverride())
}
return ctx
}
func (i PrintlnInterpreter) Param(b conflow.Block, name conflow.ID) interface{} {
switch name {
case "id":
return b.(*Println).id
case "value":
return b.(*Println).value
default:
panic(fmt.Errorf("unexpected parameter %q in Println", name))
}
}
func (i PrintlnInterpreter) SetParam(block conflow.Block, name conflow.ID, value interface{}) error {
b := block.(*Println)
switch name {
case "value":
b.value = value
}
return nil
}
func (i PrintlnInterpreter) SetBlock(block conflow.Block, name conflow.ID, key string, value interface{}) error {
return nil
}