Class: ListWish

Inherits:
Djinni::Wish
  • Object
show all
Defined in:
lib/zoom/wish/list_wish.rb

Instance Method Summary collapse

Instance Method Details

#aliases ⇒ Object



4
5
6
# File 'lib/zoom/wish/list_wish.rb', line 4

def aliases
    return ["la", "list", "ls"]
end

#description ⇒ Object



8
9
10
# File 'lib/zoom/wish/list_wish.rb', line 8

def description
    return "List details for current/all profiles"
end

#execute(args, djinni_env = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/zoom/wish/list_wish.rb', line 12

def execute(args, djinni_env = {})
    if (!args.empty? && (args != "all"))
        usage
        return
    end

    config = djinni_env["config"]
    input = djinni_env["djinni_input"]
    input = "la" if (!args.empty?)

    case input
    when "la"
        profiles = config.get_profiles
        profiles.keys.sort do |a, b|
            a.downcase <=> b.downcase
        end.each do |name|
            print_profile(profiles[name])
        end
    else
        profile = config.get_profiles[config.current_profile_name]
        print_profile(profile)
    end
end

#tab_complete(input, djinni_env = {}) ⇒ Object



49
50
51
52
# File 'lib/zoom/wish/list_wish.rb', line 49

def tab_complete(input, djinni_env = {})
    return [{}, "", ""] if (input.include?(" "))
    return [{"all" => "List all profiles"}, input, ""]
end

#usage ⇒ Object



54
55
56
57
# File 'lib/zoom/wish/list_wish.rb', line 54

def usage
    puts "#{aliases.join(", ")} [all]"
    puts "    #{description}."
end