Exemplo n.º 1
0
func NewDwimmer(stateName string, impls ...ui.UIImplementer) *Dwimmer {
	var impl ui.UIImplementer
	if len(impls) == 1 {
		impl = impls[0]
	} else {
		impl = &ui.Term{}
	}
	var store storage.StorageImplementer
	if stateName == "" {
		store = storage.Dummy()
	} else {
		store = storage.NewStorage(stateName)
	}
	result := &Dwimmer{
		Transitions:        dynamics.DefaultTransitions,
		UIImplementer:      impl,
		StorageImplementer: store,
		Stack:              &dynamics.BasicStack{},
	}
	result.InitUI()
	defer func() {
		e := recover()
		if e != nil {
			result.Close()
			panic(e)
		}
	}()
	RunDefaultInitializers(result)
	return result
}
Exemplo n.º 2
0
func TestDwimmer() *Dwimmer {
	result := &Dwimmer{
		Transitions:        dynamics.DefaultTransitions,
		UIImplementer:      ui.Dummy(),
		StorageImplementer: storage.Dummy(),
		Stack:              &dynamics.BasicStack{},
	}
	return result
}