本文整理匯總了Golang中github.com/paulfchristiano/dwimmer/dynamics.Dwimmer.Readln方法的典型用法代碼示例。如果您正苦於以下問題:Golang Dwimmer.Readln方法的具體用法?Golang Dwimmer.Readln怎麽用?Golang Dwimmer.Readln使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/paulfchristiano/dwimmer/dynamics.Dwimmer
的用法示例。
在下文中一共展示了Dwimmer.Readln方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getInput
func getInput(d dynamics.Dwimmer, context *term.SettingT, hintstrings, toolmap term.T) term.T {
quotedHints, err := represent.ToList(d, hintstrings)
if err != nil {
return represent.ConversionError.T(hintstrings, err)
}
hints := make([]string, len(quotedHints))
for i, quoted := range quotedHints {
hints[i], err = represent.ToStr(d, quoted)
if err != nil {
return represent.ConversionError.T(quoted, err)
}
}
tools := make(map[rune]string)
for toolmap.Head() != maps.Empty {
switch toolmap.Head() {
case maps.Cons:
vs := toolmap.Values()
c, err := represent.ToRune(d, vs[0])
if err != nil {
return represent.ConversionError.T(vs[0], err)
}
s, err := represent.ToStr(d, vs[1])
if err != nil {
return represent.ConversionError.T(vs[1], err)
}
tools[c] = s
toolmap = vs[2]
default:
context.AppendTerm(UnrecognizedDictionary.T())
return nil
}
}
input := d.Readln(" < ", hints, tools)
return core.Answer.T(represent.Str(input))
}
示例2: OldElicitAction
func OldElicitAction(d dynamics.Dwimmer, context *term.SettingT, subject *term.Setting, hints bool) term.ActionC {
settingS := addNames(subject)
ShowSettingS(d, settingS)
hint_strings := []string{}
tool_map := make(map[rune]string)
if hints {
hint_strings = GetHints(d, context, settingS, 6)
tools := similarity.SuggestedTemplates(d, subject, 6)
if len(hint_strings) > 0 || len(tools) > 0 {
d.Println("")
}
if len(tools) > 0 {
d.Println("")
}
tips := []rune{'a', 's', 'd', 'w', 'e', 'j'}
for i, tool := range tools {
tool_map[tips[i]] = tool.String()
d.Println(fmt.Sprintf("%c: %v", tips[i], tool))
}
if len(hint_strings) > 0 {
d.Println("")
}
for i, hint := range hint_strings {
d.Println(fmt.Sprintf("%d. %s", i, hint))
}
}
d.Println("")
for {
input := d.Readln(" < ", hint_strings, tool_map)
if input == "jump up" {
StartShell(d, Interrupted.T(represent.SettingT(context)))
}
a := parsing.ParseAction(input, settingS.Names)
if a == nil {
c := parsing.ParseTerm(input, settingS.Names)
if c != nil {
switch c := c.(type) {
case *term.CompoundC:
if questionLike(c) {
a = new(term.ActionC)
*a = term.AskC(c)
}
case term.ReferenceC:
a = new(term.ActionC)
*a = term.ViewC(c)
}
d.Println("please input an action (ask, view, return, close, delete, correct, or tell)")
} else {
d.Println("that response wasn't parsed correctly")
}
}
if a != nil {
for i, n := range a.IntArgs {
if n == -1 {
a.IntArgs[i] = subject.Size - 1
}
}
return *a
}
}
}