Class: ListWish

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

Instance Method Summary collapse

Instance Method Details

#aliasesObject



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

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

#descriptionObject



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
35
36
# 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.parse_profiles
        profiles.keys.sort do |a, b|
            a.downcase <=> b.downcase
        end.each do |name|
            print_profile(profiles[name])
        end
    else
        profile = config.get_profile(
            config.get_current_profile_name
        )
        print_profile(profile)
    end
end

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



51
52
53
54
# File 'lib/zoom/wish/list_wish.rb', line 51

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

#usageObject



56
57
58
59
# File 'lib/zoom/wish/list_wish.rb', line 56

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