Sha256: 3d58bfc80baade5b4279cd802ae4e29a9ef2b2ddb2dbbdb7d2e9313f8f60a783

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

module Templater

  module CLI

    class Manifold

      def initialize(destination_root, manifold, name, version)
        @destination_root, @manifold, @name, @version = destination_root, manifold, name, version
      end

      def version
        puts @version
        exit
      end

      def self.run(destination_root, manifold, name, version, arguments)
        if arguments.blank? || (arguments.first && ["help", "-h", "--help"].include?(arguments.first))
          Manifold.new(destination_root, manifold, name, version).run(arguments)
          return
        end

        generator_name = arguments.shift
        if generator_class = manifold.generator(generator_name)
          Generator.new(generator_name, generator_class, destination_root, name, version).run(arguments)
        else
          Manifold.new(destination_root, manifold, name, version).run(arguments)
        end
      end

      def run(arguments)
        @options = Templater::CLI::Parser.parse(arguments)
        self.help
      end

      # outputs a helpful message and quits
      def help
        puts "Usage: #{@name} generator_name [options] [args]"
        puts ''
        puts @manifold.desc
        puts ''
        puts 'Available Generators'
        @manifold.public_generators.each do |name, generator|
          print "    "
          print name.to_s.ljust(33)
          print generator.desc.to_a.first.chomp if generator.desc
          print "\n"
        end
        puts @options[:opts]
        puts ''
        exit
      end

    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
templater-0.3.4 lib/templater/cli/manifold.rb
templater-0.4.1 lib/templater/cli/manifold.rb
templater-0.4.2 lib/templater/cli/manifold.rb
templater-0.4.0 lib/templater/cli/manifold.rb
templater-0.3.5 lib/templater/cli/manifold.rb
templater-0.4.3 lib/templater/cli/manifold.rb