@@ -173,42 +173,45 @@ def show_manual_setup_screen() -> None:
173173 print (after_text )
174174
175175
176+ class _TuiLogger :
177+ def _fmt (self , msg : object , * args : object ) -> str :
178+ try :
179+ if isinstance (msg , str ) and args :
180+ return msg .format (* args )
181+ except Exception :
182+ pass
183+ return str (msg )
184+
185+ def info (self , msg : object , * args : object , ** kwargs : object ) -> None :
186+ questionary .print (self ._fmt (msg , * args ), style = "fg:ansiblue" )
187+
188+ def debug (self , msg : object , * args : object , ** kwargs : object ) -> None :
189+ questionary .print (self ._fmt (msg , * args ), style = "fg:ansiblack" )
190+
191+ def warning (self , msg : object , * args : object , ** kwargs : object ) -> None :
192+ questionary .print (self ._fmt (msg , * args ), style = "bold fg:ansiyellow" )
193+
194+ def error (self , msg : object , * args : object , ** kwargs : object ) -> None :
195+ questionary .print (self ._fmt (msg , * args ), style = "bold fg:ansired" )
196+
197+
176198@contextlib .contextmanager
177199def suppress_loguru_output () -> Generator [None , None , None ]:
178200 """Suppress loguru output."""
179201 with contextlib .suppress (Exception ):
180202 log .remove ()
203+
204+ old_logger = oauth_mod .log
205+ # Route oauth_manager's log calls to questionary for TUI output
206+ oauth_mod .log = _TuiLogger () # type: ignore[attr-defined]
181207 yield
208+ oauth_mod .log = old_logger
182209 log .add (sys .stdout , level = "INFO" )
183210
184211
185212@suppress_loguru_output ()
186213def run (* , dry_run : bool = False , skip_oauth : bool = False ) -> None : # noqa: C901
187214 """Run the complete setup process."""
188-
189- # Route oauth_manager's log calls to questionary for TUI output
190- class _TuiLogger :
191- def _fmt (self , msg : object , * args : object ) -> str :
192- try :
193- if isinstance (msg , str ) and args :
194- return msg .format (* args )
195- except Exception :
196- pass
197- return str (msg )
198-
199- def info (self , msg : object , * args : object , ** kwargs : object ) -> None :
200- questionary .print (self ._fmt (msg , * args ), style = "fg:ansiblue" )
201-
202- def debug (self , msg : object , * args : object , ** kwargs : object ) -> None :
203- questionary .print (self ._fmt (msg , * args ), style = "fg:ansiblack" )
204-
205- def warning (self , msg : object , * args : object , ** kwargs : object ) -> None :
206- questionary .print (self ._fmt (msg , * args ), style = "bold fg:ansiyellow" )
207-
208- def error (self , msg : object , * args : object , ** kwargs : object ) -> None :
209- questionary .print (self ._fmt (msg , * args ), style = "bold fg:ansired" )
210-
211- oauth_mod .log = _TuiLogger () # type: ignore[attr-defined]
212215 show_welcome_screen (dry_run = dry_run )
213216 # Additional setup steps will be added here
214217
@@ -244,15 +247,15 @@ def error(self, msg: object, *args: object, **kwargs: object) -> None:
244247# Triggered from cli.py
245248def run_import_tui (args : argparse .Namespace , force : bool = False ) -> None :
246249 """Run the import TUI, if necessary."""
247- # Find config dir, check if ".setup_tui_run " exists
250+ # Find config dir, check if ".setup_tui_ran " exists
248251 config_dir = get_config_dir ()
249252 config_dir .mkdir (parents = True , exist_ok = True )
250253
251- setup_tui_run_file = config_dir / ".setup_tui_run "
252- if not setup_tui_run_file .exists () or force :
254+ setup_tui_ran_file = config_dir / ".setup_tui_ran "
255+ if not setup_tui_ran_file .exists () or force :
253256 run (dry_run = args .wizard_dry_run , skip_oauth = args .wizard_skip_oauth )
254257
255- setup_tui_run_file .touch ()
258+ setup_tui_ran_file .touch ()
256259
257260
258261def main (argv : list [str ] | None = None ) -> int :
0 commit comments