Module: Capistrano::CLI::Help
- Defined in:
- lib/capistrano/ext/params.rb
Instance Method Summary collapse
Instance Method Details
#explain_task(config, name) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/capistrano/ext/params.rb', line 87 def explain_task(config,name) def print( task ) puts "-"*HEADER_LEN puts "Usage:\n\tcap %s %s %s" % [ $recipe, task.fully_qualified_name, [ [task.[:required]].flatten.compact.map {|param| " %s=ARG" % [param] }, [task.[:optional]].flatten.compact.map {|param| " [%s=ARG]" % [param] } ].flatten.join() ] puts "-"*HEADER_LEN puts format_text(task.description) puts "-"*HEADER_LEN if task.[:required] puts "Required Parameters" task.[:required].each do |param| param_desc = $capistrano_ext_params[param][:description] || param puts "\t#{param} - #{param_desc}" end end if task.[:optional] puts "Optional Parameters" task.[:optional].each do |param| param_details = $capistrano_ext_params[param] if param_details param_desc = "#{param_details[:description]} (default=#{param_details[:default]})" else param_desc = param end puts "\t#{param} - #{param_desc}" end end end task = config.find_task(name) # if name is for a namespace, then explain all tasks in namespace if task.nil? # Following logic adapted from Namespaces#find_task parts = name.to_s.split(/:/) ns = config until parts.empty? next_part = parts.shift ns = next_part.empty? ? nil : ns.namespaces[next_part.to_sym] return nil if ns.nil? end # print each task ns.tasks.each do |_name,_task| print( task ) puts "\n\n" end else print( task ) end end |
#original_explain_task ⇒ Object
85 |
# File 'lib/capistrano/ext/params.rb', line 85 alias_method :original_explain_task, :explain_task |
#print(task) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/capistrano/ext/params.rb', line 89 def print( task ) puts "-"*HEADER_LEN puts "Usage:\n\tcap %s %s %s" % [ $recipe, task.fully_qualified_name, [ [task.[:required]].flatten.compact.map {|param| " %s=ARG" % [param] }, [task.[:optional]].flatten.compact.map {|param| " [%s=ARG]" % [param] } ].flatten.join() ] puts "-"*HEADER_LEN puts format_text(task.description) puts "-"*HEADER_LEN if task.[:required] puts "Required Parameters" task.[:required].each do |param| param_desc = $capistrano_ext_params[param][:description] || param puts "\t#{param} - #{param_desc}" end end if task.[:optional] puts "Optional Parameters" task.[:optional].each do |param| param_details = $capistrano_ext_params[param] if param_details param_desc = "#{param_details[:description]} (default=#{param_details[:default]})" else param_desc = param end puts "\t#{param} - #{param_desc}" end end end |