Class: ViWish
- Inherits:
-
Djinni::Wish
- Object
- Djinni::Wish
- ViWish
- Defined in:
- lib/git_xplorer/wish/vi_wish.rb
Instance Method Summary collapse
- #aliases ⇒ Object
- #description ⇒ Object
- #execute(args, djinni_env = Hash.new) ⇒ Object
- #tab_complete(input, djinni_env = Hash.new) ⇒ Object
- #usage ⇒ Object
Instance Method Details
#aliases ⇒ Object
4 5 6 |
# File 'lib/git_xplorer/wish/vi_wish.rb', line 4 def aliases return ["vi", "view", "vim"] end |
#description ⇒ Object
8 9 10 |
# File 'lib/git_xplorer/wish/vi_wish.rb', line 8 def description return "Open the file in vim" end |
#execute(args, djinni_env = Hash.new) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/git_xplorer/wish/vi_wish.rb', line 12 def execute(args, djinni_env = Hash.new) gitx = djinni_env["gitXplorer"] readonly = false case djinni_env["djinni_input"] when "view" readonly = true end begin gitx.vim(args, readonly) rescue GitXplorer::Error => e puts e. end end |
#tab_complete(input, djinni_env = Hash.new) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git_xplorer/wish/vi_wish.rb', line 28 def tab_complete(input, djinni_env = Hash.new) gitx = djinni_env["gitXplorer"] _, found, partial = input.rpartition(":") _, _, partial = input.rpartition("/") if (found.empty?) completions = Hash.new gitx.get_completions(input).each do |child| completions.merge!(child.tab_complete) end return [completions, partial, ""] end |
#usage ⇒ Object
42 43 44 45 |
# File 'lib/git_xplorer/wish/vi_wish.rb', line 42 def usage puts "#{aliases.join(", ")} <file>" puts " #{description}." end |