Sha256: be45f17c16e9a9f37bbc17a8261795d1b0a6391f77bb33e40e584c38bad4a058

Contents?: true

Size: 1.62 KB

Versions: 31

Compression:

Stored size: 1.62 KB

Contents

require 'itamae-mitsurin'
require 'itamae-mitsurin/mitsurin'
require 'thor'

module ItamaeMitsurin
  module Mitsurin
    class CLI < Thor
      CREATE_TARGETS = %w[ cookbook ].freeze

#      class_option :with_git, type: :string, aliases: ['-g']

      desc "version", "Print version"
      def version
        puts "manaita(itamae-mitsurin) v#{ItamaeMitsurin::VERSION}"
      end

      desc "init", "Create a new project"
      def init
        creator = Creators::Project.new
        creator.destination_root
        creator.invoke_all
      end

      desc 'create cookbook [LAYER] [NAME]', 'Initialize cookbook (short-cut alias: "c")'
      map 'c' => 'create'
      def create(target, layer, name)
        name = layer + '/' + name
        validate_create_target!('create', target)

        creator = Creators.find(target).new
        creator.destination_root = File.join("site-cookbooks", name)
        creator.copy_files
      end

      desc 'destroy cookbook [LAYER] [NAME]', 'Undo cookbook (short-cut alias: "d")'
      map 'd' => 'destroy'
      def destroy(target, layer, name)
        name = layer + '/' + name
        validate_create_target!('destroy', target)

        creator = Creators.find(target).new
        creator.destination_root = File.join("site-cookbooks", name)
        creator.remove_files
      end

      private
      def validate_create_target!(command, target)
        unless CREATE_TARGETS.include?(target)
          msg = %Q!ERROR: "manaita #{command}" was called with "#{target}" !
          msg << "but expected to be in #{CREATE_TARGETS.inspect}"
          fail InvocationError, msg
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
itamae-mitsurin-1.0.3 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-1.0.2 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-1.0.1 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-1.0.0 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.50 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.49 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.48 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.47 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.46 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.45 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.44 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.43 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.42 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.41 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.40 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.39 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.38 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.37 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.36 lib/itamae-mitsurin/mitsurin/cli.rb
itamae-mitsurin-0.35 lib/itamae-mitsurin/mitsurin/cli.rb