From 6e1cb3ed3c03c91cbd03bbc0002db880c5fb314f Mon Sep 17 00:00:00 2001
From: David Barnett <david@mumind.me>
Date: Tue, 1 Oct 2024 20:32:51 -0600
Subject: [PATCH] Fix redundant "Ignore and refresh" prompt from `init`

---
 ChangeLog       | 1 +
 gcalcli/cli.py  | 2 ++
 gcalcli/gcal.py | 9 +++++++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f8776fa..7caf465 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 v4.5.1
   * Fix bizarre SSL recursion errors by moving truststore init earlier
+  * Fix redundant "Ignore and refresh" prompt from `init`
   * Adjust "when" value parsing to handle YYYY-MM-DD consistently
 
 v4.5.0
diff --git a/gcalcli/cli.py b/gcalcli/cli.py
index 62658cb..f9fbfda 100755
--- a/gcalcli/cli.py
+++ b/gcalcli/cli.py
@@ -236,6 +236,8 @@ def main():
             cal_names=cal_names,
             printer=printer,
             userless_mode=userless_mode,
+            # TODO: Avoid heavy unnecessary setup in general, remove override.
+            do_eager_init=parsed_args.command != 'init',
             **vars(parsed_args),
         )
 
diff --git a/gcalcli/gcal.py b/gcalcli/gcal.py
index 25645bf..d29589d 100644
--- a/gcalcli/gcal.py
+++ b/gcalcli/gcal.py
@@ -68,7 +68,12 @@ class GoogleCalendarInterface:
     UNIWIDTH = {'W': 2, 'F': 2, 'N': 1, 'Na': 1, 'H': 1, 'A': 1}
 
     def __init__(
-        self, cal_names=(), printer=PRINTER, userless_mode=False, **options
+        self,
+        cal_names=(),
+        printer=PRINTER,
+        userless_mode=False,
+        do_eager_init=True,
+        **options,
     ):
         self.cals = []
         self.printer = printer
@@ -83,7 +88,7 @@ def __init__(
                 "Running in GCALCLI_USERLESS_MODE. Most operations will fail!",
                 file=sys.stderr,
             )
-        else:
+        elif do_eager_init:
             self._get_cached()
 
         self._select_cals(cal_names)