Sha256: a92980ce95953d41f78d26a5bdabb7ff6d9173916b4cc9b6284885d08cbb7abc

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 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

    def process
      action = args.shift

      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

2 entries across 2 versions & 1 rubygems

Version Path
repo_manager-0.7.2 lib/repo_manager/actions/help_action.rb
repo_manager-0.7.1 lib/repo_manager/actions/help_action.rb