Class: S3Copy::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/commandline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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
  options = {}
  @option_parser = OptionParser.new do |opts|
    opts.banner = "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

#allObject

Returns the value of attribute all.



5
6
7
# File 'lib/commandline.rb', line 5

def all
  @all
end

#in_bucketObject

Returns the value of attribute in_bucket.



5
6
7
# File 'lib/commandline.rb', line 5

def in_bucket
  @in_bucket
end

#in_keyObject

Returns the value of attribute in_key.



5
6
7
# File 'lib/commandline.rb', line 5

def in_key
  @in_key
end

#in_secretObject

Returns the value of attribute in_secret.



5
6
7
# File 'lib/commandline.rb', line 5

def in_secret
  @in_secret
end

#out_bucketObject

Returns the value of attribute out_bucket.



5
6
7
# File 'lib/commandline.rb', line 5

def out_bucket
  @out_bucket
end

#out_keyObject

Returns the value of attribute out_key.



5
6
7
# File 'lib/commandline.rb', line 5

def out_key
  @out_key
end

#out_secretObject

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

Returns:

  • (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_helpObject



61
62
63
# File 'lib/commandline.rb', line 61

def show_help
  puts @option_parser
end