Module: Aspera::Cli::CompletionActions
- Included in:
- Plugins::Config
- Defined in:
- lib/aspera/cli/completion_actions.rb
Overview
Mixin for Config plugin: shell completion scripts, and the words they propose
Instance Method Summary collapse
-
#action_completion_candidates(words: nil) ⇒ Object
Complete the word at cursor, for completion scripts: candidates, one per line:
word, orword<TAB>description, not filtered by the word at cursor. -
#action_completion_words(words: nil) ⇒ Object
List words that can follow the given words, one per line.
Instance Method Details
#action_completion_candidates(words: nil) ⇒ Object
Complete the word at cursor, for completion scripts: candidates, one per line: word, or word<TAB>description,
not filtered by the word at cursor. Then a directive for the shell: :files or :folders (complete local paths),
followed by a space and the beginning of the word at cursor that is not part of the path, if any (e.g. --key=@file:),
:hint <text> (display text, nothing to insert), or :.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/aspera/cli/completion_actions.rb', line 84 def action_completion_candidates(words: nil, **) words = Array(words) completion = completion(words[0..-2], words.last.to_s) completion.candidates.each { |word, description| puts description.nil? ? word : "#{word}\t#{description}" } directive = if completion.files then [completion.files.eql?(:folder) ? 'folders' : 'files', completion.files_prefix].reject { |w| w.to_s.empty? }.join(' ') elsif completion.hint then "hint #{completion.hint}" end puts ":#{directive}" ::Process.exit(0) end |
#action_completion_words(words: nil) ⇒ Object
List words that can follow the given words, one per line.
When a value is expected but cannot be proposed, its type is listed (e.g. <String>), or <file> (or <folder>) for a local path.
71 72 73 74 75 76 77 |
# File 'lib/aspera/cli/completion_actions.rb', line 71 def action_completion_words(words: nil, **) completion = completion(Array(words), '') completion.candidates.each { |candidate| puts candidate.first } puts completion.hint unless completion.hint.nil? puts "<#{completion.files}>" unless completion.files.nil? ::Process.exit(0) end |