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