pub async fn run_init<R, W, Fut>(
reader: &mut R,
writer: &mut W,
config_path: &Path,
profile_arg: Option<&str>,
validate: impl Fn(String, String, String) -> Fut,
) -> Result<(), ApiError>Expand description
Interactive init flow with injectable IO and validator for testing.
validate receives (account_id, client_id, client_secret) and returns
Some(display_name) on success or None on auth failure.
The flow adapts to context:
- First-ever setup (no config file): defaults to “default” profile, shows OAuth setup URL, prompts credentials.
- Config exists, no
--profileflag: shows existing profiles and asks whether to update an existing one or add a new one. --profilegiven: updates that profile if it exists, otherwise adds it.