myl 0.9.3__py3-none-any.whl → 0.9.4__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: myl
3
- Version: 0.9.3
3
+ Version: 0.9.4
4
4
  Summary: Dead simple IMAP CLI client
5
5
  Author-email: Philipp Schmitt <philipp@schmitt.co>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -0,0 +1,7 @@
1
+ myl.py,sha256=7cluVkTXZ3P3OqsmFt-UGw0gVeszVPrRTtwJMhW3jXo,14909
2
+ myl-0.9.4.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
+ myl-0.9.4.dist-info/METADATA,sha256=eRJywRLPB_y5g0wS7za44MfPqWzGEJbplbFs_4W8CJo,43447
4
+ myl-0.9.4.dist-info/WHEEL,sha256=EaM1zKIUYa7rQnxGiOCGhzJABRwy4WO57rWMR3_tj4I,91
5
+ myl-0.9.4.dist-info/entry_points.txt,sha256=q6nr0Kzim7JzreXQE3BTU4asLh2sx5-D0w1yLBOcHxc,33
6
+ myl-0.9.4.dist-info/top_level.txt,sha256=Wn88OJVVWyYSsKVoqzlHXxfFxh5IbrJ_Yw-ldNLe7Po,4
7
+ myl-0.9.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.9.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
myl.py CHANGED
@@ -98,6 +98,17 @@ def parse_args():
98
98
  default=None,
99
99
  )
100
100
 
101
+ # get most recent email
102
+ last_parser = subparsers.add_parser(
103
+ "last", aliases=["-1"], help="Retrieve the most recent email"
104
+ )
105
+ last_parser.add_argument(
106
+ "ATTACHMENT",
107
+ help="Name of the attachment to fetch",
108
+ nargs="?",
109
+ default=None,
110
+ )
111
+
101
112
  # Delete email command
102
113
  delete_parser = subparsers.add_parser("delete", help="Delete an email")
103
114
  delete_parser.add_argument(
@@ -301,15 +312,23 @@ def mb_connect(console, args) -> BaseMailBox:
301
312
 
302
313
  def display_single_mail(
303
314
  mailbox: BaseMailBox,
304
- mail_id: int,
315
+ mail_id: int | None = None,
305
316
  attachment: str | None = None,
306
317
  mark_seen: bool = False,
307
318
  raw: bool = False,
308
319
  html: bool = False,
309
320
  json: bool = False,
310
321
  ):
311
- LOGGER.debug("Fetch mail %s", mail_id)
312
- msg = next(mailbox.fetch(f"UID {mail_id}", mark_seen=mark_seen))
322
+ if mail_id is None:
323
+ LOGGER.debug("No mail_id provided, fetching the most recent mail")
324
+ msg = next(
325
+ mailbox.fetch(
326
+ "ALL", reverse=True, bulk=True, limit=1, mark_seen=mark_seen
327
+ )
328
+ )
329
+ else:
330
+ LOGGER.debug("Fetch mail %s", mail_id)
331
+ msg = next(mailbox.fetch(f"UID {mail_id}", mark_seen=mark_seen))
313
332
  LOGGER.debug("Fetched mail %s", msg)
314
333
 
315
334
  if attachment:
@@ -476,6 +495,17 @@ def main() -> int:
476
495
  json=args.json,
477
496
  )
478
497
 
498
+ elif args.command in ["-1", "last"]:
499
+ return display_single_mail(
500
+ mailbox=mailbox,
501
+ mail_id=None,
502
+ attachment=args.ATTACHMENT,
503
+ mark_seen=args.mark_seen,
504
+ raw=args.raw,
505
+ html=args.html,
506
+ json=args.json,
507
+ )
508
+
479
509
  # mark emails as read
480
510
  elif args.command in ["read"]:
481
511
  return mark_read(
@@ -1,7 +0,0 @@
1
- myl.py,sha256=8CCrgsD1DhmbZycNJk24XLf_hgESRsf6ku1d6DyUOfA,13954
2
- myl-0.9.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
- myl-0.9.3.dist-info/METADATA,sha256=jy8hkerCv6mVFN2Qwv4JoLFE7ZOMoLcKL_zs_cRzTag,43447
4
- myl-0.9.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
- myl-0.9.3.dist-info/entry_points.txt,sha256=q6nr0Kzim7JzreXQE3BTU4asLh2sx5-D0w1yLBOcHxc,33
6
- myl-0.9.3.dist-info/top_level.txt,sha256=Wn88OJVVWyYSsKVoqzlHXxfFxh5IbrJ_Yw-ldNLe7Po,4
7
- myl-0.9.3.dist-info/RECORD,,
File without changes