imapcli 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee39530d31868e3c8f3c90a1ad9957552ee91f51e7ed05c57fb9a3724a297ef7
4
- data.tar.gz: 3d6484ebcce956fc9425447786daaf6d7bce486e0b787d5be9e817cba4517dab
3
+ metadata.gz: 0736f0dbe2cb473770fb5f92f0f37546b9f26a6e892bbca3c69b072c1f06db9f
4
+ data.tar.gz: '0609a383ac74799eb2aade3d52fa0c5c811fc5cb4b253f1607e0b6f2dbe7cf01'
5
5
  SHA512:
6
- metadata.gz: 0e6fab7ebd5c9e58b432323e7ee974c8880785ccf969139966ac2bc9bc7f1034db51678e95c35d7fb53a7df434790340c03aedd40bf2d1bfb6308b2d6b6d4614
7
- data.tar.gz: 44801f7d7aa3311683b7e2370b39b9738d4de629e080f32f034b6ae6ac65bda0882dfc15d3731af3929421757a350217f8e4a74ec2127f35d543215cf8aef84e
6
+ metadata.gz: 69d818a1780fda1549bbd83581c2d0abbc4ecda7274cb411bedd450a8365e322153263c1f5b490b03a183e7c8cb02e5d382c82c8628ee43e1c1c1294f6e76afa
7
+ data.tar.gz: e664577a0949609bebd90a7bc08b94e4559001fcb7b26429958fe38801acd835089b030cad3d3b1fa09a95ccc51b400f6cb8f66befc4903ebe1cb9b4bb56746d
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Version 2.1.0 (2025-03-16)][v2.1.0]
9
+
10
+ ### Added
11
+
12
+ - New command-line flag `-l`/`--limit` to limit the statistics output to
13
+ a given number of mailboxes (folders).
14
+
8
15
  ## [Version 2.0.1 (2025-03-11)][v2.0.1]
9
16
 
10
17
  ### Fixed
@@ -72,6 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
72
79
  - Fix: Docker image.
73
80
  - Fix: Options error message.
74
81
 
82
+ [v2.1.0]: https://github.com/bovender/imapcli/releases/tag/v2.1.0
75
83
  [v2.0.1]: https://github.com/bovender/imapcli/releases/tag/v2.0.1
76
84
  [v2.0.0]: https://github.com/bovender/imapcli/releases/tag/v2.0.0
77
85
  [v1.0.7]: https://github.com/bovender/imapcli/releases/tag/v1.0.7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- imapcli (2.0.0)
4
+ imapcli (2.0.1)
5
5
  activesupport (~> 8.0)
6
6
  csv
7
7
  descriptive_statistics (~> 2.5)
@@ -16,7 +16,7 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- activesupport (8.0.1)
19
+ activesupport (8.0.2)
20
20
  base64
21
21
  benchmark (>= 0.3)
22
22
  bigdecimal
@@ -83,7 +83,7 @@ GEM
83
83
  pp (>= 0.6.0)
84
84
  rdoc (>= 4.0.0)
85
85
  reline (>= 0.4.2)
86
- json (2.10.1)
86
+ json (2.10.2)
87
87
  language_server-protocol (3.17.0.4)
88
88
  lint_roller (1.1.0)
89
89
  listen (3.9.0)
@@ -92,7 +92,7 @@ GEM
92
92
  logger (1.6.6)
93
93
  lumberjack (1.2.10)
94
94
  method_source (1.1.0)
95
- minitest (5.25.4)
95
+ minitest (5.25.5)
96
96
  nenv (0.3.0)
97
97
  net-imap (0.5.6)
98
98
  date
@@ -142,7 +142,7 @@ GEM
142
142
  diff-lcs (>= 1.2.0, < 2.0)
143
143
  rspec-support (~> 3.13.0)
144
144
  rspec-support (3.13.2)
145
- rubocop (1.73.2)
145
+ rubocop (1.74.0)
146
146
  json (~> 2.3)
147
147
  language_server-protocol (~> 3.17.0.2)
148
148
  lint_roller (~> 1.1.0)
@@ -153,7 +153,7 @@ GEM
153
153
  rubocop-ast (>= 1.38.0, < 2.0)
154
154
  ruby-progressbar (~> 1.7)
155
155
  unicode-display_width (>= 2.4.0, < 4.0)
156
- rubocop-ast (1.38.1)
156
+ rubocop-ast (1.39.0)
157
157
  parser (>= 3.3.1.0)
158
158
  rubocop-performance (1.24.0)
159
159
  lint_roller (~> 1.1)
data/README.md CHANGED
@@ -263,7 +263,18 @@ keyword, as shown below.
263
263
 
264
264
  Example:
265
265
 
266
- bundle exec -it bin/imapcli -s yourserver.example.com -u myusername -P stats -r -o max_size Archive
266
+ docker run -it bin/imapcli -s yourserver.example.com -u myusername -P stats -r -o max_size Archive
267
+
268
+ #### Limiting the number of mailboxes
269
+
270
+ You can limit the number of mailboxes (folders) in the output table with the
271
+ `-l`/`--limit` flag. This flag takes an argument that indicates the maximum
272
+ number of mailboxes. THe default value for this argument is 10.
273
+
274
+ Use case: Say you have a very large IMAP account, and you would like to know the
275
+ 5 folders that contain the largest messages. The command should be:
276
+
277
+ imapcli -s yourserver.example.com -u myusername -P stats -o max_size --limit 5
267
278
 
268
279
  #### Obtaining comma-separated values (CSV)
269
280
 
data/lib/imapcli/cli.rb CHANGED
@@ -74,6 +74,10 @@ module Imapcli
74
74
  default: 'total_size'
75
75
  c.switch %i[reverse], desc: 'Reverse sort order (largest first)', negatable: false
76
76
  c.switch [:csv], desc: 'Output comma-separated values (CSV)'
77
+ c.flag %i[l limit],
78
+ desc: 'Limit the results to n folders (IMAP mailboxes)',
79
+ arg_name: 'max_lines',
80
+ default: 10
77
81
 
78
82
  c.action do |_global_options, options, args| # rubocop:disable Metrics/BlockLength
79
83
  raise unless @validator.stats_options_valid?(options, args)
@@ -68,7 +68,12 @@ module Imapcli
68
68
  yield current_count if block_given?
69
69
  end
70
70
  end
71
- output = sorted_list(list, options).map do |mailbox|
71
+
72
+ output = if options[:limit]
73
+ sorted_list(list, options).last(options[:limit].to_i)
74
+ else
75
+ sorted_list(list, options)
76
+ end.map do |mailbox|
72
77
  stats_to_table(mailbox.full_name, mailbox.stats)
73
78
  end
74
79
  output << stats_to_table('Total', total_stats) if list.length > 1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Imapcli
4
- VERSION = '2.0.1'
4
+ VERSION = '2.1.0'
5
5
  end
@@ -133,6 +133,11 @@ RSpec.describe Imapcli::Command do
133
133
  expect(output).to be_a Array
134
134
  expect(output[0][0]).to eq 'Inbox/Smallest/Messages'
135
135
  end
136
+
137
+ it 'returns only the first n mailboxes' do
138
+ output = command.stats('Inbox', depth: -1, limit: 2)
139
+ expect(output.length).to eq 3 # including summary line
140
+ end
136
141
  end
137
142
 
138
143
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imapcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Kraus (bovender)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-11 00:00:00.000000000 Z
11
+ date: 2025-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport