Sha256: ec7fa5a0fcbede9119143f62a3288b057778fee28f12e18f97c6bd8f2bdd0d2b
Contents?: true
Size: 1.79 KB
Versions: 3
Compression:
Stored size: 1.79 KB
Contents
#!/usr/bin/env ruby $:.unshift File.join(File.dirname(__FILE__),'..','lib') # require 'rubygems' require 'optparse' require 'etc' require 'logger' require 'yaml' require 'escoffier' def parse_options options = Hash.new parser = OptionParser.new do |opts| opts.banner = "Usage: normalize_directory.rb [options] list of directories." # opts.on('-d', '--directory DIR', "Directory to Normalize") do |dir| # abort # options[:directory] = dir # end opts.on('-u', '--user USER', "The user who should own the files.") do |user| abort "Cannot find user #{user}." unless Etc.getpwnam(user) options[:user] = user end opts.on('-g', '--group GROUP', "The group who should own the files.") do |group| abort "Cannot find group #{group}." unless Etc.getgrnam(group) options[:group] = group end opts.on('-s', '--spec FILE', "A configuration file of directories.") do |file| options[:specfile] = file end opts.on('--dry-run', "Display Ownership Changes but don't make them.") do options[:dry_run] = true end opts.on_tail('-h', '--help', "Show this message") { puts(parser); exit } opts.on_tail("Example: normalize_directory.rb -u raw -g raw /Data/vtrak1/raw") end parser.parse!(ARGV) return options end def normalize!(options) directories = ARGV.to_a directories.each do |directory| unless File.directory?(directory) puts "Error: Cannot find directory #{directory}." next end normalizer = Normalizer.new(directory, options) normalizer.normalize_directory! end end if File.basename(__FILE__) == File.basename($PROGRAM_NAME) $LOG = Logger.new(STDOUT) options = parse_options # if options[:spec] # directories = # end normalize!(options) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
escoffier-0.1.3 | bin/normalize_directory.rb |
escoffier-0.1.2 | bin/normalize_directory.rb |
escoffier-0.1.1 | bin/normalize_directory.rb |