Sha256: d33e6721dba328072946a5e655225fb0be452c9209bdf227a4c849cfc6d3326f

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'fileutils'
require 'optparse'

class Loom
  @options = {}
  
  def self.generate_new_loom(dir)
    if dir.nil?
      puts "Unable to generate new loom project, dir is nil"
    else
      if @options[:verbose] then puts "Making directory #{dir}" end
        
      create_directory dir
      
      #TODO These templates either need to be bundled with the gem, 
      #or downloadedfrom the server.
      #FileUtils.cp_r "/Users/natebeck/Desktop/LoomScriptDev/.", dir
    end
  end

  def self.process()

    OptionParser.new do |opts|
      opts.banner = "Usage: example.rb [options]"

      opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
        @options[:verbose] = v
      end
    end.parse!

    if @options[:verbose] then puts "I AM VERBOSE!" end

    #p options
    #p ARGV

    action = ARGV[0]

    case action
    when "new"
      generate_new_loom ARGV[1]
    when "init", "s"
      puts "Do it here!"
    else
      puts "Whatcha trying to do?"
      # TODO Run Help
    end
  end
  
  private
  
  def self.create_directory(path)
    if !File.directory?(path)
      FileUtils.mkdir_p path
        puts "Created directory: #{path}"
    else
        puts "Skipped directory: #{path}" unless(path == Dir.pwd)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loom-0.0.2 lib/loom.rb