Skip to main content

AnthropicConfig

Struct AnthropicConfig 

Source
pub struct AnthropicConfig {
    pub enabled: bool,
    pub credentials_path: Option<PathBuf>,
    pub accounts: Vec<AnthropicAccount>,
    pub accounts_dir: Option<PathBuf>,
    pub show_default_account: bool,
}

Fields§

§enabled: bool§credentials_path: Option<PathBuf>

Override the credentials file path (defaults to ~/.claude/.credentials.json). This is the default account; extra subscriptions go in accounts.

§accounts: Vec<AnthropicAccount>

Extra Anthropic accounts beyond the default, each selected on the CLI with --account <label> (issue #14). Empty by default, so existing single-account configs are byte-for-byte unchanged.

§accounts_dir: Option<PathBuf>

Directory to auto-discover extra accounts from, in Claude Code’s own CLAUDE_CONFIG_DIR layout: each immediate subdirectory becomes an account labeled by the subdirectory name. The credentials may live in that directory’s .credentials.json or in the macOS Keychain, so discovery intentionally does not probe for the credentials file. Merged with accounts (explicit wins on a label clash); each is refreshed independently.

§show_default_account: bool

Whether the default (unnamed) Claude account gets its own tab. Defaults to true for back-compat. Set false when every account is managed explicitly (via accounts/accounts_dir) so the ambient Keychain/~/.claude login doesn’t add a redundant “Claude” tab. Ignored when there are no named accounts, so Anthropic never loses its only tab.

Implementations§

Source§

impl AnthropicConfig

Source

pub fn all_accounts(&self) -> Vec<AnthropicAccount>

Every extra account: the explicit [[anthropic.accounts]] entries plus any auto-discovered under accounts_dir. Explicit entries take precedence on a label clash. This is what tabs and --account enumerate, so a discovered account behaves exactly like a hand-written one (own cache subdir, independent refresh).

Source

pub fn account(&self, label: &str) -> Result<AnthropicAccount>

Find an extra account by label (explicit or discovered), or error listing the known labels so a typo fails loudly instead of silently hitting the default. Returns an owned account because discovered entries are synthesized, not stored.

Source

pub fn account_target(&self, label: &str) -> Result<(CredsTarget, Cache)>

Resolve a named account to the credentials target + isolated cache it fetches through: CredsTarget::Named, which on macOS prefers the Keychain item scoped to the file’s own directory (that is where CLAUDE_CONFIG_DIR=<dir> claude actually writes) and falls back to the file elsewhere — never a different account’s item, since the hash is per-directory, so issue #15’s cross-account concern doesn’t apply. Plus an anthropic/<label> cache subdir. Shared by the widget (--account) and the TUI’s per-account tab (#14, #17) so both resolve accounts identically; the widget layers its --cache-dir override on top of the cache returned here.

Trait Implementations§

Source§

impl Clone for AnthropicConfig

Source§

fn clone(&self) -> AnthropicConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AnthropicConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AnthropicConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AnthropicConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AnthropicConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more