Class: S3Sync::CLI::List
- Defined in:
- lib/s3sync/cli.rb
Instance Attribute Summary collapse
-
#max_entries ⇒ Object
Returns the value of attribute max_entries.
Instance Method Summary collapse
-
#initialize ⇒ List
constructor
A new instance of List.
- #run(s3, bucket, key, file, args) ⇒ Object
Methods inherited from BaseCmd
#execute, #has_options?, #has_prefix?, #usage
Constructor Details
#initialize ⇒ List
Returns a new instance of List.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/s3sync/cli.rb', line 181 def initialize super 'list', takes_commands: false #, false @short_desc = "List items filed under a given bucket" @max_entries = 0 @delimiter = "\t" @has_prefix = true self. do |opt| opt.on("-m", "--max-entries=NUM", "Limit the number of entries to output") {|m| @max_entries = m } opt.on("-d", "--delimiter=D", "Charactere used to separate columns") {|d| @delimiter = d } end end |
Instance Attribute Details
#max_entries ⇒ Object
Returns the value of attribute max_entries.
179 180 181 |
# File 'lib/s3sync/cli.rb', line 179 def max_entries @max_entries end |
Instance Method Details
#run(s3, bucket, key, file, args) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/s3sync/cli.rb', line 203 def run s3, bucket, key, file, args raise WrongUsage.new(nil, "You need to inform a bucket") if not bucket collection = s3.bucket(bucket).objects( prefix: (key || "") ) if @max_entries > 0 collection = collection.page(:per_page => @max_entries) end collection.each {|object| o = [] o << object.key o << @delimiter o << object.content_length o << @delimiter o << object.last_modified puts o.join } end |