Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
added more instructions to the help prompt for select and multi select (
Browse files Browse the repository at this point in the history
#129)

* added more instructions to the help prompt for select and multi select

* added new instructions to tests
  • Loading branch information
AlecAivazis authored Mar 11, 2018
1 parent 12f3e71 commit 9d3458c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
6 changes: 2 additions & 4 deletions multiselect.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var MultiSelectQuestionTemplate = `
{{- color "default+hb"}}{{ .Message }}{{ .FilterMessage }}{{color "reset"}}
{{- if .ShowAnswer}}{{color "cyan"}} {{.Answer}}{{color "reset"}}{{"\n"}}
{{- else }}
{{- if and .Help (not .ShowHelp)}} {{color "cyan"}}[{{ HelpInputRune }} for help]{{color "reset"}}{{end}}
{{- " "}}{{- color "cyan"}}[Use arrows to move, type to filter{{- if and .Help (not .ShowHelp)}}, {{ HelpInputRune }} for more help{{end}}]{{color "reset"}}
{{- "\n"}}
{{- range $ix, $option := .PageEntries}}
{{- if eq $ix $.SelectedIndex}}{{color "cyan"}}{{ SelectFocusIcon }}{{color "reset"}}{{else}} {{end}}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (m *MultiSelect) OnChange(line []rune, pos int, key rune) (newLine []rune,
m.filter = ""
} else if key == terminal.KeyDelete || key == terminal.KeyBackspace {
if m.filter != "" {
m.filter = m.filter[0:len(m.filter)-1]
m.filter = m.filter[0 : len(m.filter)-1]
}
} else if key >= terminal.KeySpace {
m.filter += string(key)
Expand Down Expand Up @@ -159,8 +159,6 @@ func (m *MultiSelect) filterOptions() []string {
return answer
}



func (m *MultiSelect) Prompt() (interface{}, error) {
// compute the default state
m.checked = make(map[string]bool)
Expand Down
6 changes: 3 additions & 3 deletions multiselect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestMultiSelectRender(t *testing.T) {
PageEntries: prompt.Options,
Checked: map[string]bool{"bar": true, "buz": true},
},
`? Pick your words:
`? Pick your words: [Use arrows to move, type to filter]
◯ foo
◉ bar
❯ ◯ baz
Expand All @@ -63,7 +63,7 @@ func TestMultiSelectRender(t *testing.T) {
PageEntries: prompt.Options,
Checked: map[string]bool{"bar": true, "buz": true},
},
`? Pick your words: [? for help]
`? Pick your words: [Use arrows to move, type to filter, ? for more help]
◯ foo
◉ bar
❯ ◯ baz
Expand All @@ -80,7 +80,7 @@ func TestMultiSelectRender(t *testing.T) {
ShowHelp: true,
},
`ⓘ This is helpful
? Pick your words:
? Pick your words: [Use arrows to move, type to filter]
◯ foo
◉ bar
❯ ◯ baz
Expand Down
4 changes: 2 additions & 2 deletions select.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var SelectQuestionTemplate = `
{{- color "default+hb"}}{{ .Message }}{{ .FilterMessage }}{{color "reset"}}
{{- if .ShowAnswer}}{{color "cyan"}} {{.Answer}}{{color "reset"}}{{"\n"}}
{{- else}}
{{- if and .Help (not .ShowHelp)}} {{color "cyan"}}[{{ HelpInputRune }} for help]{{color "reset"}}{{end}}
{{- " "}}{{- color "cyan"}}[Use arrows to move, type to filter{{- if and .Help (not .ShowHelp)}}, {{ HelpInputRune }} for more help{{end}}]{{color "reset"}}
{{- "\n"}}
{{- range $ix, $choice := .PageEntries}}
{{- if eq $ix $.SelectedIndex}}{{color "cyan+b"}}{{ SelectFocusIcon }} {{else}}{{color "default+hb"}} {{end}}
Expand Down Expand Up @@ -102,7 +102,7 @@ func (s *Select) OnChange(line []rune, pos int, key rune) (newLine []rune, newPo
s.filter = ""
} else if key == terminal.KeyDelete || key == terminal.KeyBackspace {
if s.filter != "" {
s.filter = s.filter[0:len(s.filter)-1]
s.filter = s.filter[0 : len(s.filter)-1]
}
} else if key >= terminal.KeySpace {
s.filter += string(key)
Expand Down
6 changes: 3 additions & 3 deletions select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestSelectRender(t *testing.T) {
"Test Select question output",
prompt,
SelectTemplateData{SelectedIndex: 2, PageEntries: prompt.Options},
`? Pick your word:
`? Pick your word: [Use arrows to move, type to filter]
foo
bar
❯ baz
Expand All @@ -52,7 +52,7 @@ func TestSelectRender(t *testing.T) {
"Test Select question output with help hidden",
helpfulPrompt,
SelectTemplateData{SelectedIndex: 2, PageEntries: prompt.Options},
`? Pick your word: [? for help]
`? Pick your word: [Use arrows to move, type to filter, ? for more help]
foo
bar
❯ baz
Expand All @@ -64,7 +64,7 @@ func TestSelectRender(t *testing.T) {
helpfulPrompt,
SelectTemplateData{SelectedIndex: 2, ShowHelp: true, PageEntries: prompt.Options},
`ⓘ This is helpful
? Pick your word:
? Pick your word: [Use arrows to move, type to filter]
foo
bar
❯ baz
Expand Down

0 comments on commit 9d3458c

Please sign in to comment.