Class: S3Ranger::CLI::CreateBucket
- Inherits:
-
CmdParse::Command
- Object
- CmdParse::Command
- S3Ranger::CLI::CreateBucket
- Defined in:
- lib/s3ranger/cli.rb
Instance Attribute Summary collapse
-
#acl ⇒ Object
Returns the value of attribute acl.
Instance Method Summary collapse
-
#initialize ⇒ CreateBucket
constructor
A new instance of CreateBucket.
- #run(s3, bucket, key, file, args) ⇒ Object
Constructor Details
#initialize ⇒ CreateBucket
Returns a new instance of CreateBucket.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/s3ranger/cli.rb', line 32 def initialize super 'createbucket', false, false @short_desc = "Create a new bucket under your user account" @acl = nil self. = CmdParse::OptionParserWrapper.new do |opt| opt.on("-a", "--acl=ACL", "Options: #{AVAILABLE_ACLS.join ', '}") {|acl| @acl = acl.to_sym } end end |
Instance Attribute Details
#acl ⇒ Object
Returns the value of attribute acl.
30 31 32 |
# File 'lib/s3ranger/cli.rb', line 30 def acl @acl end |
Instance Method Details
#run(s3, bucket, key, file, args) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/s3ranger/cli.rb', line 46 def run s3, bucket, key, file, args raise WrongUsage.new(nil, "You need to inform a bucket") if not bucket begin params = {} if @acl raise WrongUsage.new(nil, "Invalid ACL `#{@acl}'. Should be any of #{AVAILABLE_ACLS.join ', '}") if not AVAILABLE_ACLS.include? @acl params.merge!({:acl => @acl}) end s3.buckets.create bucket, params rescue AWS::S3::Errors::BucketAlreadyExists => exc raise FailureFeedback.new("Bucket `#{bucket}' already exists") end end |