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 'rubygems'
require 'find' require 'find'
require 'optparse'
if ARGV.length < 1 options = {:target_path => nil, :clientbucket_path => nil}
puts "Usage: clientbucket.rb /path/to/file /path/to/clientbucket" parser = OptionParser.new do |opts|
exit 1 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
opts.on("-c", "--clientbucket_path clientbucket_path", "path to file to restore") do |c|
options[:clientbucket_path] = c
end
end end
target_path,clientbucket_path = ARGV parser.parse!
clientbucket_path ||= "/var/lib/puppet/clientbucket"
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 available_files = Array.new