added option parser

This commit is contained in:
Rilindo Foster 2016-05-20 21:46:38 -05:00
parent 497d5e6ed4
commit 1c93e8bb47

View File

@ -2,14 +2,36 @@
require 'rubygems'
require 'find'
require 'optparse'
if ARGV.length < 1
puts "Usage: clientbucket.rb /path/to/file /path/to/clientbucket"
exit 1
options = {:target_path => nil, :clientbucket_path => nil}
parser = OptionParser.new do |opts|
opts.banner = "Usage: clientbucket.rb -t target_path -c clientbucket_path"
opts.on("-t", "--target_path target_path", "path to file to restore") do |t|
options[:target_path] = t
end
target_path,clientbucket_path = ARGV
clientbucket_path ||= "/var/lib/puppet/clientbucket"
opts.on("-c", "--clientbucket_path clientbucket_path", "path to file to restore") do |c|
options[:clientbucket_path] = c
end
end
parser.parse!
if options[:target_path] == nil
print 'Enter target path: '
options[:target_path] = gets.chomp
end
if options[:clientbucket_path] == nil
print 'Enter clientbucket path: '
options[:clientbucket_path] = gets.chomp
end
target_path = options[:target_path]
clientbucket_path = options[:clientbucket_path]
available_files = Array.new