forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csi_param_state.go
38 lines (30 loc) · 838 Bytes
/
csi_param_state.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
package ansiterm
type CsiParamState struct {
BaseState
}
func (csiState CsiParamState) Handle(b byte) (s State, e error) {
logger.Infof("CsiParam::Handle %#x", b)
nextState, err := csiState.BaseState.Handle(b)
if nextState != nil || err != nil {
return nextState, err
}
switch {
case sliceContains(Alphabetics, b):
return csiState.parser.Ground, nil
case sliceContains(CsiCollectables, b):
csiState.parser.collectParam()
return csiState, nil
case sliceContains(Executors, b):
return csiState, csiState.parser.execute()
}
return csiState, nil
}
func (csiState CsiParamState) Transition(s State) error {
logger.Infof("CsiParam::Transition %s --> %s", csiState.Name(), s.Name())
csiState.BaseState.Transition(s)
switch s {
case csiState.parser.Ground:
return csiState.parser.csiDispatch()
}
return nil
}