Method: HighLine#shell_style_lambda
- Defined in:
- lib/highline.rb
#shell_style_lambda(menu) ⇒ lambda
Convenience method to craft a lambda suitable for beind used in autocompletion operations by #choose
292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/highline.rb', line 292 def shell_style_lambda() lambda do |command| # shell-style selection first_word = command.to_s.split.first || "" = . .extend(OptionParser::Completion) answer = .complete(first_word) raise Question::NoAutoCompleteMatch unless answer [answer.last, command.sub(/^\s*#{first_word}\s*/, "")] end end |