#!/usr/bin/env ruby require 'getoptlong' require 'proutils/mint/copier' module Mint # Scaffolding Console Command # # IMPORTANT: When using system lookup, all globs must be in quotes!!! class Command # Start command. def self.start new.start end # New scaffolding command. def initialize @options = {} @cmd = 'copy' # default command opts = GetoptLong.new( ['--system', '-s', GetoptLong::NO_ARGUMENT], ['--dryrun', '--noharm', '-n', GetoptLong::NO_ARGUMENT], ['--skip', GetoptLong::NO_ARGUMENT], ['--replace', GetoptLong::NO_ARGUMENT], ['--help', '-h', GetoptLong::NO_ARGUMENT] ) opts.each do |k,v| case k when '--dryrun' @options[:dryrun] = true when '--safe' @options[:skip] = true when '--replace' @options[:force] = true when '--system' @options[:system] = true when '--help' @cmd = 'help' end end end # def options @options end # Start execution. def start send(@cmd) end # Copy scaffolding. def copy begin destination = ARGV.pop resource = ARGV.dup copier = Copier.new(resource, destination, options) copier.copy rescue LoadError puts "Unrecognized source, '#{src}'." exit 0 end end # Get help. def help $stdout << DATA.read exit -1 end # def __DIR__ File.dirname(__FILE__) end end end Mint::Command.start __END__ Mint v0.2.0 Usage: mint [-s] [destination] Opitons: -s --source Source path starts in mint paths. --skip Skip all duplicates. --replace Replace all duplicates. --svn (NOT IMPLEMTENTED YET) Create subversion branches/ tags/ trunk/ directories at the top level. -n --noharm --dryrun Only pretend to create files. --help Display's this help information. Built-in Sources: website Start a website. ruby Create a standard ruby project layout. Examples: To copy a directory: $ mint ~/pictures ~/copy_of_pictures/ To copy a selection of files: $ mint ~/pictures/*.jpg ~/copy_of_pictures/ To scaffold a new ruby project in the current directory. $ mint -s ruby . To scaffold a new website to a new directory. $ mint -s website mysite/ To copy a single file, for instance: $ mint -s ruby/meta/name-1.0.0.roll meta/