Skip to main content

Cli

Struct Cli 

Source
pub struct Cli {
Show 18 fields pub vendor: Option<Vendor>, pub icon: Option<String>, pub format: Option<String>, pub tooltip_format: Option<String>, pub pace_tolerance: u32, pub format_pace_color: bool, pub tooltip_pace_pts: bool, pub color_low: Option<String>, pub color_mid: Option<String>, pub color_high: Option<String>, pub color_critical: Option<String>, pub pretty: bool, pub json: bool, pub watch: Option<u64>, pub cycle_next: bool, pub cycle_prev: bool, pub cache_dir: Option<PathBuf>, pub creds_path: Option<PathBuf>,
}

Fields§

§vendor: Option<Vendor>

Which vendor to query. When omitted, reads [ui] primary from ~/.config/ai-usagebar/config.toml; falls back to anthropic if neither is set.

§icon: Option<String>

Optional icon prepended to the bar text (Nerd Font glyph / emoji / Pango span). claudebar --icon.

§format: Option<String>

Bar-text format string with {placeholder} substitutions. Defaults to {session_pct}% · {session_reset}.

§tooltip_format: Option<String>

Custom tooltip format. Overrides the default bordered tooltip when set; identical placeholder set as --format.

§pace_tolerance: u32

Tolerance band (in percentage points) for ratio-based pacing icons.

§format_pace_color: bool

Color pace placeholders individually per window (instead of the global usage-based color). Claudebar --format-pace-color.

§tooltip_pace_pts: bool

Use point-based pacing in the tooltip’s pace column (vs ratio-based). Also enables an elapsed-position marker on the tooltip progress bars. Claudebar --tooltip-pace-pts.

§color_low: Option<String>

Override the low-usage color (#RRGGBB).

§color_mid: Option<String>

Override the mid-usage color (#RRGGBB).

§color_high: Option<String>

Override the high-usage color (#RRGGBB).

§color_critical: Option<String>

Override the critical-usage color (#RRGGBB).

§pretty: bool

Render human-readable terminal output (ANSI colors + box drawing) instead of Waybar JSON. Auto-on when stdout is a TTY.

§json: bool

Force JSON output even on a TTY (useful when piping into jq from an interactive shell).

§watch: Option<u64>

Re-render every N seconds, clearing the screen between ticks. Implies --pretty. Press Ctrl-C to exit.

§cycle_next: bool

Cycle the persisted “active vendor” forward and exit. Wire to Waybar’s on-scroll-up to scroll-cycle through enabled vendors. Sends SIGRTMIN+13 to waybar afterwards so the bar refreshes immediately rather than waiting for the next interval tick.

§cycle_prev: bool

Cycle backwards. Wire to on-scroll-down.

§cache_dir: Option<PathBuf>

Override the cache directory (for tests / debugging).

§creds_path: Option<PathBuf>

Override the credentials file path (for tests / debugging).

Implementations§

Source§

impl Cli

Source

pub fn resolved_vendor(&self, config: &Config) -> Vendor

Resolve the vendor with full precedence:

  1. explicit --vendor (highest)
  2. persisted scroll-cycle state (~/.cache/ai-usagebar/active_vendor)
  3. [ui] primary from config
  4. anthropic (lowest)
Source§

impl Cli

Source

pub fn output_json(&self) -> bool

True when we should emit Waybar JSON. Default behavior: JSON when stdout is piped, pretty when on a TTY (unless --json is set).

Trait Implementations§

Source§

impl Args for Cli

Source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

impl Clone for Cli

Source§

fn clone(&self) -> Cli

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 CommandFactory for Cli

Source§

fn command<'b>() -> Command

Build a Command that can instantiate Self. Read more
Source§

fn command_for_update<'b>() -> Command

Build a Command that can update self. Read more
Source§

impl Debug for Cli

Source§

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

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

impl FromArgMatches for Cli

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl Parser for Cli

Source§

fn parse() -> Self

Parse from std::env::args_os(), exit on error.
Source§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
Source§

fn parse_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error.
Source§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
Source§

fn update_from<I, T>(&mut self, itr: I)
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error. Read more
Source§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.

Auto Trait Implementations§

§

impl Freeze for Cli

§

impl RefUnwindSafe for Cli

§

impl Send for Cli

§

impl Sync for Cli

§

impl Unpin for Cli

§

impl UnsafeUnpin for Cli

§

impl UnwindSafe for Cli

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> 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: 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: 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