Class: S3Sync::CLI::BaseCmd
- Inherits:
-
CmdParse::Command
- Object
- CmdParse::Command
- S3Sync::CLI::BaseCmd
show all
- Defined in:
- lib/s3sync/cli.rb
Instance Method Summary
collapse
Instance Method Details
#execute(*args) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/s3sync/cli.rb', line 66
def execute(*args)
s3 = Aws::S3::Resource.new(client: Aws::S3::Client.new)
key, file = args
bucket = nil
bucket, key = key.split(':') if key
begin
run s3, bucket, key, file, args
rescue Aws::S3::Errors::SignatureDoesNotMatch, Aws::S3::Errors::InvalidAccessKeyId => e
raise FailureFeedback.new("Access Denied: #{e.message}")
rescue Aws::S3::Errors::NoSuchBucket
raise FailureFeedback.new("There's no bucket named `#{bucket}'")
rescue Aws::S3::Errors::NoSuchKey
raise FailureFeedback.new("There's no key named `#{key}' in the bucket `#{bucket}'")
rescue Aws::S3::Errors::ServiceError => exc
raise FailureFeedback.new("Error: `#{exc.message}'")
end
end
|
#has_options? ⇒ Boolean
43
44
45
|
# File 'lib/s3sync/cli.rb', line 43
def has_options?
not options.instance_variables.empty?
end
|
#has_prefix? ⇒ Boolean
47
48
49
|
# File 'lib/s3sync/cli.rb', line 47
def has_prefix?
@has_prefix
end
|
#usage ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/s3sync/cli.rb', line 51
def usage
u = []
u << "Usage: #{File.basename commandparser.program_name} #{name} "
u << "[options] " if has_options?
u << "bucket" if has_args?
if has_prefix? == 'required'
u << ':prefix'
elsif has_prefix?
u << "[:prefix]"
end
u.join ''
end
|