Class: CatWish

Inherits:
Djinni::Wish
  • Object
show all
Defined in:
lib/git_xplorer/wish/cat_wish.rb

Instance Method Summary collapse

Instance Method Details

#aliasesObject



4
5
6
# File 'lib/git_xplorer/wish/cat_wish.rb', line 4

def aliases
    return ["cat"]
end

#descriptionObject



8
9
10
# File 'lib/git_xplorer/wish/cat_wish.rb', line 8

def description
    return "Display file contents"
end

#execute(args, djinni_env = Hash.new) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/git_xplorer/wish/cat_wish.rb', line 12

def execute(args, djinni_env = Hash.new)
    gitx = djinni_env["gitXplorer"]

    begin
        gitx.show(args)
    rescue GitXplorer::Error => e
        puts e.message
    end
end

#tab_complete(input, djinni_env = Hash.new) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/git_xplorer/wish/cat_wish.rb', line 22

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

#usageObject



36
37
38
39
# File 'lib/git_xplorer/wish/cat_wish.rb', line 36

def usage
    puts "#{aliases.join(", ")} <file>"
    puts "    #{description}."
end