Sha256: 71221946ab979852d179e7e674a75e8213478fc1451bd9cdd85d9101552da411

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

#!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__),'..','lib')

require 'optparse'
require 'etc'
require 'pathname'
require 'logger'
require 'tmpdir'
require 'escoffier'

def parse_options
  options = Hash.new
  parser = OptionParser.new do |opts|
    opts.banner = "Usage: #{__FILE__} [options] source_paths destination"

    # opts.on('-o', '--output OUTPUT_DIRECTORY', "Output Destination Directory")     do |dir| 
    #   options[:output] = dir
    #   abort "Cannot find directory #{dir}." unless File.directory?(File.dirname(dir))
    # end
    
    opts.on('-t', '--temp', "Make a temporary directory for output")     do |dir| 
      options[:mktmpdir] = true
      abort "Output directory already specified - not creating a temporary directory." if options[:dir] 
    end
    
    # opts.on('-f', '--[no-]force', "Force Overwrite of the sandbox") do |f|
    #   options[:force] = f
    # end
    
    opts.on('-v', '--[no-]verbose', "Get detailed output") do |v|
      options[:verbose] = v
    end

    opts.on_tail('-h', '--help',          "Show this message")          { puts(parser); exit }
	opts.on_tail("Example: #{__FILE__} /Data/vtrak1/raw/gallagher.pd/mri/pd005b/009 /tmp")
  end

  parser.parse!(ARGV)
  puts parser unless ARGV.size >= 2
  return options
end

def prep_mise(directories, options)
  if options[:mktmpdir]
    begin 
      destination = Dir.mktmpdir      
    rescue
      begin 
        destination = Dir.tmpdir
      rescue
        destination = '/tmp/'
      end
    end
  else
    destination = directories.pop
  end
  
  directories.each do |directory|   
    directory.prep_mise_to(destination)
  end
      
end

if File.basename(__FILE__) == File.basename($PROGRAM_NAME)
  $LOG = Logger.new(STDOUT)
  $LOG.level = Logger::INFO
  
  options = parse_options
  directories = ARGV.collect { |dir| Pathname.new(dir) }
  prep_mise(directories, options)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
escoffier-0.1.3 bin/mise~
escoffier-0.1.2 bin/mise~
escoffier-0.1.1 bin/mise~
escoffier-0.1.0 bin/mise~