pub fn resolve_token(
cli_token: Option<&str>,
ledger_auth: &LedgerAuth,
) -> Result<Option<String>, TokenError>Expand description
Attempts to resolve a crates.io API token from three sources in priority order.
cli_tokenargument (highest priority – for scripting and CI).ledger_auth.token_env: reads the named environment variable.ledger_auth.token_cmd: runs the command string in a shell and captures stdout. Only one oftoken_envortoken_cmdis used (env takes precedence if both set).- Fall through to
~/.cargo/credentials.toml[registry] tokenfield.
Returns Ok(Some(token)) if any tier succeeds, Ok(None) if no token found
(caller decides whether to proceed – cargo itself may have credentials).
§Errors
Returns TokenError::EnvVarEmpty if token_env is set but the variable is empty.
Returns TokenError::CmdFailed if token_cmd fails or produces no output.
Returns TokenError::CargoCredentials if credentials.toml exists but is unreadable.