Class: S3Copy::CommandLine
- Inherits:
-
Object
- Object
- S3Copy::CommandLine
- Defined in:
- lib/commandline.rb
Instance Attribute Summary collapse
-
#all ⇒ Object
Returns the value of attribute all.
-
#in_bucket ⇒ Object
Returns the value of attribute in_bucket.
-
#in_key ⇒ Object
Returns the value of attribute in_key.
-
#in_secret ⇒ Object
Returns the value of attribute in_secret.
-
#out_bucket ⇒ Object
Returns the value of attribute out_bucket.
-
#out_key ⇒ Object
Returns the value of attribute out_key.
-
#out_secret ⇒ Object
Returns the value of attribute out_secret.
Instance Method Summary collapse
-
#initialize(args) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #missing_arguments? ⇒ Boolean
- #show_help ⇒ Object
Constructor Details
#initialize(args) ⇒ CommandLine
Returns a new instance of CommandLine.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/commandline.rb', line 7 def initialize(args) # Handle options = {} @option_parser = OptionParser.new do |opts| opts. = "Usage: #{opts.program_name} [options]" opts.separator "" opts.separator "Specific options:" # in key opts.on(:REQUIRED,"--in_key S3KEY","The S3 amazon key to use for the in bucket.") do |val| @in_key = val end # in secret opts.on(:REQUIRED,"--in_secret S3SECRET","The S3 amazon secret to use for the in bucket.") do |val| @in_secret = val end # in bucket opts.on(:REQUIRED,"--in_bucket BUCKET","The name of the bucket to copy from.") do |val| @in_bucket = val end # out key opts.on(:REQUIRED,"--out_key S3KEY","The S3 amazon key to use for the out bucket.") do |val| @out_key = val end # out secret opts.on(:REQUIRED,"--out_secret S3SECRET","The S3 amazon secret to use for the out bucket.") do |val| @out_secret = val end # out bucket opts.on(:REQUIRED,"--out_bucket BUCKET","The name of the bucket to copy to.") do |val| @out_bucket = val end # all files opts.on(:OPTIONAL,"--all","Copy all of the files. If this is omitted filenames will be read from STDIN.") do |val| @all = val end # No argument, shows at tail. This will print an options summary. opts.on_tail("-?", "--help", "Show this message") do puts opts exit end end # parse options @option_parser.parse!(ARGV) end |
Instance Attribute Details
#all ⇒ Object
Returns the value of attribute all.
5 6 7 |
# File 'lib/commandline.rb', line 5 def all @all end |
#in_bucket ⇒ Object
Returns the value of attribute in_bucket.
5 6 7 |
# File 'lib/commandline.rb', line 5 def in_bucket @in_bucket end |
#in_key ⇒ Object
Returns the value of attribute in_key.
5 6 7 |
# File 'lib/commandline.rb', line 5 def in_key @in_key end |
#in_secret ⇒ Object
Returns the value of attribute in_secret.
5 6 7 |
# File 'lib/commandline.rb', line 5 def in_secret @in_secret end |
#out_bucket ⇒ Object
Returns the value of attribute out_bucket.
5 6 7 |
# File 'lib/commandline.rb', line 5 def out_bucket @out_bucket end |
#out_key ⇒ Object
Returns the value of attribute out_key.
5 6 7 |
# File 'lib/commandline.rb', line 5 def out_key @out_key end |
#out_secret ⇒ Object
Returns the value of attribute out_secret.
5 6 7 |
# File 'lib/commandline.rb', line 5 def out_secret @out_secret end |
Instance Method Details
#missing_arguments? ⇒ Boolean
65 66 67 |
# File 'lib/commandline.rb', line 65 def missing_arguments? return (@in_key.nil? or @in_secret.nil? or @in_bucket.nil? or @out_bucket.nil?) end |
#show_help ⇒ Object
61 62 63 |
# File 'lib/commandline.rb', line 61 def show_help puts @option_parser end |