Class: Crew::CLI::Contexts
- Inherits:
-
Object
- Object
- Crew::CLI::Contexts
- Includes:
- Processor
- Defined in:
- lib/crew/cli/contexts.rb
Instance Method Summary collapse
- #edit(args) ⇒ Object
- #help(args) ⇒ Object
- #help_message ⇒ Object
- #info(args) ⇒ Object
- #list(args) ⇒ Object
- #new(args) ⇒ Object
- #process(args) ⇒ Object
- #remove(args) ⇒ Object
Methods included from Processor
Instance Method Details
#edit(args) ⇒ Object
32 33 34 35 36 |
# File 'lib/crew/cli/contexts.rb', line 32 def edit(args) context_name = args.shift raise "You must specify a context name" if context_name.nil? crew_home.context_edit(context_name) end |
#help(args) ⇒ Object
50 51 52 53 54 |
# File 'lib/crew/cli/contexts.rb', line 50 def help(args) puts "# Crew #{Crew::VERSION}".color(:magenta) puts puts end |
#help_message ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/crew/cli/contexts.rb', line 56 def <<-HEREDOCS #{"Contexts ".bright} #{"===============================".bright} #{"contexts help ".color(:blue).bright}provides help #{"contexts list ".color(:blue).bright}lists all the tasks currently installed #{"contexts new (context name) ".color(:blue).bright}lists all the tasks available to be installed #{"contexts remove (context name) ".color(:blue).bright}updates the specified task (or all of them) #{"contexts edit (context name) ".color(:blue).bright}lists all the tasks available to be installed HEREDOCS end |
#info(args) ⇒ Object
38 39 40 41 42 |
# File 'lib/crew/cli/contexts.rb', line 38 def info(args) context_name = args.shift raise "You must specify a context name" if context_name.nil? crew_home.context_info(context_name) end |
#list(args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/crew/cli/contexts.rb', line 20 def list(args) max_name_length = 0 crew_home.contexts do |context_name, context| max_name_length = [max_name_length, context_name.size].max end crew_home.contexts do |context_name, context| space_count = max_name_length - context_name.size + 1 puts "[#{context_name.color(:cyan)}]#{" " * space_count}Using #{context.adapter_name} adapter from #{context.source}" end end |
#new(args) ⇒ Object
14 15 16 17 18 |
# File 'lib/crew/cli/contexts.rb', line 14 def new(args) context_name = args.shift raise "You must specify a context name" if context_name.nil? crew_home.context_new(context_name) end |
#process(args) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/crew/cli/contexts.rb', line 6 def process(args) cmds = commands global_opts = Trollop::(args) do stop_on cmds end dispatch(args) end |
#remove(args) ⇒ Object
44 45 46 47 48 |
# File 'lib/crew/cli/contexts.rb', line 44 def remove(args) context_name = args.shift raise "You must specify a context name" if context_name.nil? crew_home.context_remove(context_name) end |