-
-
Save anonymous/b9a917465644d8e18d043f5500f1329b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def checkFlagValue(flag,value) | |
# Remove the = symbol, which OptionParser leaves there if you use the shortflag (-p) | |
value=value.gsub('=','') | |
if value.empty? | |
usage("Missing value for --#{flag}") | |
end | |
return value | |
end | |
# If we have the correct number of arguments let's make sure we have the required options. | |
Arguments = OptionParser.new do |opt| | |
opt.on('--profile PROFILE',"The AWS profile to connect to.") do |o| | |
profile=checkFlagValue('profile',o) | |
end | |
opt.on('--region [REGION]','The AWS region to use.') do |o| | |
region=checkFlagValue('region',o) | |
end | |
opt.on('--retention-days [DAYS]','The number of days to hold the snapshots.') do |o| | |
retention_days=checkFlagValue('retention_days',o) | |
end | |
opt.on('--[no-]dry-run','Test rather than actually running.') do |o| | |
dry_run = true | |
end | |
opt.on('--instance instance','The instance id you want to snapshot') do |o| | |
instance = o | |
end | |
end.parse! | |
def usage(optional_message = nil) | |
unless optional_message.nil? | |
puts optional_message | |
end | |
puts Arguments.help | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment