Sha256: 6890a4a25398270f691ac4137f3b8685f38d665c155ed23b8a043e3d932cbd17

Contents?: true

Size: 979 Bytes

Versions: 2

Compression:

Stored size: 979 Bytes

Contents

module Stack
  class Runner
    attr_accessor :configuration
    attr_accessor :command
    attr_accessor :arguments
    attr_accessor :generator
    
    def initialize(argv)
      @argv = argv
      @options = { }
      
      parse!
    end
    
    # Parse options, command and arguments 
    def parse!
      options = Stack::parse! @argv
      
      @configuration = Stack::Configuration.new(options)
      
      @command = @argv.shift
      @arguments = @argv
    end
    
    # Run stack!
    def run!
      if @command.nil?
        @command = "generate"
      end
      
      if Stack::COMMANDS.include?(@command)
        run_command
      else
        abort "Unknown command: #{@command}. Use one of #{Stack::COMMANDS.join(", ")}."
      end
    end
    
    # Runs the specified command 
    def run_command
      @generator = Stack::Generator.new(Stack::runner.configuration.source, Stack::runner.configuration.target)
      @generator.transform!
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stack-0.0.5 lib/stack/runner.rb
stack-0.0.4 lib/stack/runner.rb