/
context.go
61 lines (49 loc) · 1.64 KB
/
context.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
package generator
import (
"bufio"
"github.com/udmire/observability-operator/pkg/apps/manifest"
)
const (
StatusAppBuilding int = iota // Start to build an app, should given the appname and version
StatusComponentBuilding // Start to build a component in the app.
StatusFileBuilding // Start to build a file in app layer or component layer
StatusFileBuilded // File builded, to start a new session or return parent
StatusComponentBuilded // Component builded, to start a new component session
StatusAppBuilded // App builded, to start the content generating.
StatusAppGenerateFailed // App content writing, incase failure.
StatusAppGenerated // Generated, next to finished or modify
)
// Build AppManifests from model.
type AppBuilder interface {
Build() *manifest.AppManifests
}
type NextOperation interface {
NextOperation(scanner *bufio.Scanner) []Operation
// 列出可选类型,并选择
Create(scanner *bufio.Scanner) OperationHolder
Modify(scanner *bufio.Scanner) OperationHolder
Remove(scanner *bufio.Scanner)
General(scanner *bufio.Scanner) GeneralCommand
}
type OperationHolder interface {
Type() string
Args() []string
ArgsExample() string
ParseArgs(input string) error
String() string
}
type Operation int
const (
Create Operation = iota
Modify
Remove
General
)
var Operations = []Operation{Create, Modify, Remove, General}
type GeneralCommand string
const (
OP_NOOP GeneralCommand = "noop"
OP_Finish GeneralCommand = "finished"
OP_Cancel GeneralCommand = "cancel"
OP_Generate GeneralCommand = "generate"
)