Class: ListDirectoryWish
- Inherits:
-
Djinni::Wish
- Object
- Djinni::Wish
- ListDirectoryWish
- Defined in:
- lib/git_xplorer/wish/list_directory_wish.rb
Instance Method Summary collapse
- #aliases ⇒ Object
- #description ⇒ Object
- #execute(args, djinni_env = Hash.new) ⇒ Object
-
#initialize ⇒ ListDirectoryWish
constructor
A new instance of ListDirectoryWish.
- #tab_complete(input, djinni_env = Hash.new) ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize ⇒ ListDirectoryWish
39 40 41 |
# File 'lib/git_xplorer/wish/list_directory_wish.rb', line 39 def initialize @space = 4 end |
Instance Method Details
#aliases ⇒ Object
4 5 6 |
# File 'lib/git_xplorer/wish/list_directory_wish.rb', line 4 def aliases return ["ls", "ll"] end |
#description ⇒ Object
8 9 10 |
# File 'lib/git_xplorer/wish/list_directory_wish.rb', line 8 def description return "List directory contents or file revisions" end |
#execute(args, djinni_env = Hash.new) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/git_xplorer/wish/list_directory_wish.rb', line 12 def execute(args, djinni_env = Hash.new) gitx = djinni_env["gitXplorer"] long = false case djinni_env["djinni_input"] when "ll" long = true end if (args.match(/(^| )(-l|--long)( |$)/)) args.gsub!(/(^| )(-l|--long)( |$)/, "") long = true end begin children = gitx.ls(args) if (long) long(children) else children.each do |child| puts child end end rescue GitXplorer::Error => e puts e. end end |
#tab_complete(input, djinni_env = Hash.new) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/git_xplorer/wish/list_directory_wish.rb', line 72 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
86 87 88 89 90 91 92 |
# File 'lib/git_xplorer/wish/list_directory_wish.rb', line 86 def usage puts "#{aliases.join(", ")} [OPTIONS] [directory/file]" puts " #{description}." puts puts "OPTIONS" puts " -l, --long Show more info for files" end |