Sha256: 241879148cdb4c3f89afbbbd0232cc65c58d115fdf4343f82f3219dbf21be9cd

Contents?: true

Size: 1.08 KB

Versions: 22

Compression:

Stored size: 1.08 KB

Contents

module Bourdain
  module Commands

    class GenerateCommand < Command
      usage :command, <<-END
        Generate various things. Take that, Chef DK!
        generate [<options>] <generator>
        <generator>
      END

      def initialize argv
        generators               = Bourdain::Registry.specs('generator')
        maybe_generator_position = generators.map { |c| argv.index c[:name].to_s }.compact.shift
        generator_position       = maybe_generator_position.nil? ? argv.length : maybe_generator_position
        generator_name           = argv[generator_position]

        options = argv.slice(0, generator_position)
        argv    = argv.slice(generator_position, argv.length)

        super options

        generator = nil
        generator = argv.shift unless maybe_generator_position.nil?
        Trollop::die 'Invalid <generator> provided' if generator.nil?
        generator = Bourdain::Registry.klass('generator', generator_name)
        Trollop::die 'Invalid <generator> provided' if generator.nil?

        @status = generator.new(argv).status
      end
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bourdain-1.6.3 lib/bourdain/resources/commands/generate.rb
bourdain-1.6.2 lib/bourdain/resources/commands/generate.rb
bourdain-1.6.1 lib/bourdain/resources/commands/generate.rb
bourdain-1.6.0 lib/bourdain/resources/commands/generate.rb
bourdain-1.5.1 lib/bourdain/resources/commands/generate.rb
bourdain-1.5.0 lib/bourdain/resources/commands/generate.rb
bourdain-1.4.1 lib/bourdain/resources/commands/generate.rb
bourdain-1.4.0 lib/bourdain/resources/commands/generate.rb
bourdain-1.3.3 lib/bourdain/resources/commands/generate.rb
bourdain-1.3.2 lib/bourdain/resources/commands/generate.rb
bourdain-1.3.1 lib/bourdain/resources/commands/generate.rb
bourdain-1.3.0 lib/bourdain/resources/commands/generate.rb
bourdain-1.2.22 lib/bourdain/resources/commands/generate.rb
bourdain-1.2.21 lib/bourdain/resources/commands/generate.rb
bourdain-1.2.20 lib/bourdain/resources/commands/generate.rb
bourdain-1.2.19 lib/bourdain/resources/commands/generate.rb
bourdain-1.2.18 lib/bourdain/resources/commands/generate.rb
bourdain-1.2.17 lib/bourdain/resources/commands/generate.rb
bourdain-1.2.16 lib/bourdain/resources/commands/generate.rb
bourdain-1.2.15 lib/bourdain/resources/commands/generate.rb