Sha256: 9633b9c68d49dd891561a3f38820a78700b331e2739c731d85b32a1e66767701
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
#################################################### # The file is was originally cloned from "Basic App" # More information on "Basic App" can be found in the # "Basic App" repository. # # See http://github.com/robertwahler #################################################### require 'optparse' module RepoManager # @group CLI actions # # CLI help # # Provide help for an action # # @example Usage: repo help [action] class HelpAction < AppAction # Add action specific options def parse_options super do |opts| opts.on("--actions", "List available actions") do |a| options[:actions] = a end end end def process parse_options action = args.shift if options[: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 def help super :comment_starting_with => "CLI help", :located_in_file => __FILE__ end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
repo_manager-0.7.3 | lib/repo_manager/actions/help_action.rb |