Sha256: cc2d9048889987c8ca7f3911b513308cb46f555b71ef24ce8b921ec1fefc4672

Contents?: true

Size: 876 Bytes

Versions: 9

Compression:

Stored size: 876 Bytes

Contents

require 'optparse'

module Rubigen
  class CLI
    attr_reader :stdout
    
    def self.execute(stdout, arguments, runtime_arguments = {})
      self.new.execute(stdout, arguments, runtime_arguments)
    end

    def execute(stdout, arguments, runtime_arguments = {})
      @stdout = stdout
      main_usage and return unless scope = arguments.shift
      scopes = scope.split(",").map(&:to_sym)
      
      runtime_arguments.merge!(:stdout => stdout, :no_exit => true)
      RubiGen::Base.logger = RubiGen::SimpleLogger.new(stdout)

      require 'rubigen/scripts/generate'
      RubiGen::Base.use_component_sources!(scopes)
      RubiGen::Scripts::Generate.new.run(arguments, runtime_arguments)
    end
    
    def main_usage
      stdout.puts <<-USAGE.gsub(/^        /, '')
      Usage: $0 scope generator [options for generator]
      USAGE
      true
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubigen-1.5.8 lib/rubigen/cli.rb
rubigen-1.5.7 lib/rubigen/cli.rb
rubigen-1.5.6 lib/rubigen/cli.rb
rubigen-1.5.5 lib/rubigen/cli.rb
rubigen-1.5.4 lib/rubigen/cli.rb
rubigen-1.5.3 lib/rubigen/cli.rb
rubigen-1.5.2 lib/rubigen/cli.rb
rubigen-1.5.1 lib/rubigen/cli.rb
rubigen-1.5.0 lib/rubigen/cli.rb