@@ -37,7 +37,8 @@ func NewRootCommand(execer exec.Execer, out io.Writer) (cmd *cobra.Command) {
37
37
flags .BoolVarP (& opt .loop , "loop" , "" , true , "Run the Markdown in loop mode." )
38
38
flags .BoolVarP (& opt .keepFilter , "keep-filter" , "" , true , "Indicate if keep the filter." )
39
39
flags .BoolVarP (& opt .keepScripts , "keep-scripts" , "" , false , "Indicate if keep the temporary scripts." )
40
- flags .IntVarP (& opt .pageSize , "page-size" , "" , 6 , "Number of the select items." )
40
+ flags .IntVarP (& opt .pageSize , "page-size" , "" , 8 , "Number of the select items." )
41
+ flags .StringVarP (& opt .filter , "filter" , "" , "" , "Filter of the scripts" )
41
42
return
42
43
}
43
44
@@ -157,6 +158,7 @@ type option struct {
157
158
keepFilter bool
158
159
keepScripts bool
159
160
pageSize int
161
+ filter string
160
162
161
163
execer exec.Execer
162
164
}
@@ -168,10 +170,19 @@ func (o *option) executeScripts(scriptRunners ScriptRunners) (err error) {
168
170
selector := & survey.MultiSelect {
169
171
Message : "Choose the code block to run" ,
170
172
Options : scriptRunners .GetTitles (),
173
+ VimMode : true ,
171
174
}
172
175
var titles []string
173
176
if err = survey .AskOne (selector , & titles ,
174
177
survey .WithKeepFilter (o .keepFilter ),
178
+ survey .WithFilter (func (filter , value string , index int ) (include bool ) {
179
+ include = true
180
+ value = strings .ToLower (value )
181
+ if o .filter != "" && value != "quit" {
182
+ include = strings .Contains (value , o .filter )
183
+ }
184
+ return
185
+ }),
175
186
survey .WithPageSize (o .pageSize )); err != nil {
176
187
return
177
188
}
0 commit comments