Class: UseWish
- Inherits:
-
Djinni::Wish
- Object
- Djinni::Wish
- UseWish
- Defined in:
- lib/zoom/wish/use_wish.rb
Instance Method Summary collapse
- #aliases ⇒ Object
- #description ⇒ Object
- #execute(args, djinni_env = {}) ⇒ Object
- #tab_complete(input, djinni_env = {}) ⇒ Object
- #usage ⇒ Object
Instance Method Details
#aliases ⇒ Object
4 5 6 |
# File 'lib/zoom/wish/use_wish.rb', line 4 def aliases return ["use"] end |
#description ⇒ Object
8 9 10 |
# File 'lib/zoom/wish/use_wish.rb', line 8 def description return "Set the specifed profile as the current profile name" 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 |
# File 'lib/zoom/wish/use_wish.rb', line 12 def execute(args, djinni_env = {}) if (args.include?(" ")) usage return end config = djinni_env["config"] if (!config.has_profile?(args)) puts("Profile does not exist: #{args}") return end config.set_current_profile_name(args) # Update prompt prompt_color = djinni_env["prompt_color"] if (prompt_color) prompt = "zoom(#{args})> ".send(prompt_color) else prompt = "zoom(#{args})> " end djinni_env["djinni_prompt"] = prompt end |
#tab_complete(input, djinni_env = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/zoom/wish/use_wish.rb', line 37 def tab_complete(input, djinni_env = {}) return [{}, "", ""] if (input.include?(" ")) profiles = djinni_env["config"].parse_profiles completions = Hash.new profiles.keys.sort do |a, b| a.downcase <=> b.downcase end.each do |name| profile = profiles[name] completions[name] = profile.to_s.split("\n")[1].strip end completions.keep_if do |name, desc| name.downcase.start_with?(input.downcase) end return [completions, input, " "] end |
#usage ⇒ Object
57 58 59 60 |
# File 'lib/zoom/wish/use_wish.rb', line 57 def usage puts("#{aliases.join(", ")} <name>") puts(" #{description}.") end |