Sha256: bfd083ba6426c4af485b205e7a07d51684b6edbe749ea13f70f3019ae6ffd4c5

Contents?: true

Size: 789 Bytes

Versions: 3

Compression:

Stored size: 789 Bytes

Contents

module Rpub
  # The +Commander+ module is responsible for invoking `Command` objects. This is
  # the internal part of the library that is used by the CLI.
  #
  # The +Commander+ takes a list of arguments, which would typically come from the CLI,
  # and tries to look up a +Command+ class. If it cannot find anything, it will invoke
  # the {Rpub::Commands::Main} command.
  #
  # @see Rpub::Commands::Base
  # @see Rpub::Commands
  module Commander
    def invoke(args = [])
      subcommand, *options = args
      Commands::Base.matching(subcommand).new(options).invoke
    rescue SubclassTracker::NoSuchSubclass
      Commands::Main.new(args).invoke
    rescue NoConfiguration
      abort 'The current directory does not look like an rpub project.'
    end

    extend self
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rpub-0.4.0 lib/rpub/commander.rb
rpub-0.3.0 lib/rpub/commander.rb
rpub-0.2.1 lib/rpub/commander.rb