Class: Crew::CLI::Tasks
- Inherits:
-
Object
- Object
- Crew::CLI::Tasks
- Includes:
- Processor
- Defined in:
- lib/crew/cli/tasks.rb
Instance Method Summary collapse
- #available(args) ⇒ Object
- #diff(args) ⇒ Object
- #edit(args) ⇒ Object
- #help(args) ⇒ Object
- #help_message ⇒ Object
- #info(args) ⇒ Object
- #install(args) ⇒ Object
- #install_all(args) ⇒ Object
- #list(args) ⇒ Object
- #new(args) ⇒ Object
- #process(args) ⇒ Object
- #remove(args) ⇒ Object
- #update(args) ⇒ Object
Methods included from Processor
Instance Method Details
#available(args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/crew/cli/tasks.rb', line 33 def available(args) sources = Set.new crew_home.available do |task, installed| unless sources.include?(task.from_source) puts "#{task.from_source}\n#{'=' * task.from_source.size}" sources << task.from_source end print ' ' print installed ? "i".color(:blue) : " " print task.untested? ? "!".color(:red) : " " puts " %-30s : %s" % [task.name.bright, task.desc.color("#888888")] end end |
#diff(args) ⇒ Object
29 30 31 |
# File 'lib/crew/cli/tasks.rb', line 29 def diff(args) crew_home.task_diff end |
#edit(args) ⇒ Object
70 71 72 73 74 |
# File 'lib/crew/cli/tasks.rb', line 70 def edit(args) task_name = args.shift raise "You must specify a task name" if task_name.nil? crew_home.task_edit(task_name) end |
#help(args) ⇒ Object
98 99 100 101 102 |
# File 'lib/crew/cli/tasks.rb', line 98 def help(args) puts "# Crew #{Crew::VERSION}".color(:magenta) puts puts end |
#help_message ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/crew/cli/tasks.rb', line 104 def <<-HEREDOCS #{"Tasks ".bright} #{"===============================".bright} #{"tasks help ".color(:blue).bright}provides help #{"tasks list ".color(:blue).bright}lists all the tasks currently installed #{"tasks available ".color(:blue).bright}lists all the tasks available to be installed #{"tasks update (task name) ".color(:blue).bright}updates the specified task (or all of them) #{"tasks diff (task name) ".color(:blue).bright}shows the differences between the task from source and your local copy #{"tasks install [task name] ".color(:blue).bright}installs a task #{"tasks remove [task name] ".color(:blue).bright}removes a task #{"tasks new [task name] ".color(:blue).bright}edits a task #{"tasks edit [task name] ".color(:blue).bright}edits a task #{"tasks info [task name] ".color(:blue).bright}shows information about a specific task HEREDOCS end |
#info(args) ⇒ Object
76 77 78 79 80 |
# File 'lib/crew/cli/tasks.rb', line 76 def info(args) task_name = args.shift raise "You must specify a task name" if task_name.nil? crew_home.task_info(task_name) end |
#install(args) ⇒ Object
82 83 84 85 86 |
# File 'lib/crew/cli/tasks.rb', line 82 def install(args) task_name = args.shift raise "You must specify a task name" if task_name.nil? crew_home.task_install(task_name) end |
#install_all(args) ⇒ Object
88 89 90 |
# File 'lib/crew/cli/tasks.rb', line 88 def install_all(args) crew_home.task_install_all end |
#list(args) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/crew/cli/tasks.rb', line 47 def list(args) max_name_length = 0 crew_home.task_list do |task| max_name_length = [max_name_length, task.name.size].max end crew_home.task_list do |task| install = if task.installed? "i".color(:green) else ' ' end test_status = if task.untested? "x".color(:red).blink elsif task.passing? "√".color(:green) else 'f'.color(:red) end print ' ' + install + test_status puts " %-#{max_name_length}s : %s" % [task.name, task.desc] end end |
#new(args) ⇒ Object
14 15 16 17 18 |
# File 'lib/crew/cli/tasks.rb', line 14 def new(args) task_name = args.shift raise "You must specify a task name" if task_name.nil? crew_home.new(task_name) end |
#process(args) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/crew/cli/tasks.rb', line 6 def process(args) cmds = commands global_opts = Trollop::(args) do stop_on cmds end dispatch(args) end |
#remove(args) ⇒ Object
92 93 94 95 96 |
# File 'lib/crew/cli/tasks.rb', line 92 def remove(args) task_name = args.shift raise "You must specify a task name" if task_name.nil? crew_home.task_remove(task_name) end |
#update(args) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/crew/cli/tasks.rb', line 20 def update(args) opts = Trollop::(args) do opt :all, "Update all", short: "-a" end task_name = args.shift raise "must specify task name or use -a to update all tasks" if task_name.nil? && !opts[:all] crew_home.task_update(task_name) end |