Class: RepoManager::HelpAction
- Inherits:
-
AppAction
- Object
- BaseAction
- AppAction
- RepoManager::HelpAction
- Defined in:
- lib/repo_manager/actions/help_action.rb
Overview
CLI help
Provide help for an action
Instance Attribute Summary
Attributes inherited from BaseAction
#args, #configuration, #exit_code, #option_parser, #options, #output, #template
CLI actions collapse
- #help ⇒ Object
-
#parse_options ⇒ Object
Add action specific options.
- #process ⇒ Object
Methods inherited from AppAction
Methods inherited from BaseAction
#after_execute, #asset_options, #asset_type, #assets, #before_execute, #execute, #initialize, #items, #overwrite_output?, #render, #write_to_output
Constructor Details
This class inherits a constructor from RepoManager::BaseAction
Instance Method Details
#help ⇒ Object
67 68 69 |
# File 'lib/repo_manager/actions/help_action.rb', line 67 def help super :comment_starting_with => "CLI help", :located_in_file => __FILE__ end |
#parse_options ⇒ Object
Add action specific options
22 23 24 25 26 27 28 29 30 |
# File 'lib/repo_manager/actions/help_action.rb', line 22 def super do |opts| opts.on("--actions", "List available actions") do |a| [:actions] = a end end end |
#process ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/repo_manager/actions/help_action.rb', line 32 def process action = args.shift if [:actions] AVAILABLE_ACTIONS.each do |act| puts act end exit(0) unless action end unless action puts "no action specified" puts "Usage: repo help action | repo --help" puts "" puts "Where 'action' is one of: #{AVAILABLE_ACTIONS.join(' ')}" exit(0) end action = action.downcase unless AVAILABLE_ACTIONS.include?(action) puts "invalid help action: #{action}" exit(0) end klass = Object.const_get('RepoManager').const_get("#{action.capitalize}Action") app_action = klass.new(['--help'], configuration) app_action.option_parser = self.option_parser result = app_action.execute exit(0) end |