pub struct ConsoleBuilder { /* private fields */ }Expand description
Builder for Console, allowing detection to be overridden.
Implementations§
Source§impl ConsoleBuilder
impl ConsoleBuilder
Sourcepub fn log_time(self, value: bool) -> Self
pub fn log_time(self, value: bool) -> Self
Show the time column in Console::log (default on). Port of
Console(log_time=…).
Sourcepub fn log_path(self, value: bool) -> Self
pub fn log_path(self, value: bool) -> Self
Show the caller’s file and line in Console::log (default on).
Port of Console(log_path=…).
Sourcepub fn log_time_format(self, format: impl Into<String>) -> Self
pub fn log_time_format(self, format: impl Into<String>) -> Self
The strftime format of the time column in Console::log
(default "[%X]"). Port of Console(log_time_format="…"); the time
is formatted in UTC (see get_datetime).
Sourcepub fn log_time_formatter(
self,
format: impl Fn(SystemTime) -> Text + Send + Sync + 'static,
) -> Self
pub fn log_time_formatter( self, format: impl Fn(SystemTime) -> Text + Send + Sync + 'static, ) -> Self
Format the time column of Console::log with format. Port of
Console(log_time_format=callable).
Sourcepub fn get_datetime(
self,
clock: impl Fn() -> SystemTime + Send + Sync + 'static,
) -> Self
pub fn get_datetime( self, clock: impl Fn() -> SystemTime + Send + Sync + 'static, ) -> Self
Read the time Console::log shows from clock (default
SystemTime::now). Port of
Console(get_datetime=…). Upstream’s datetime.now() is local
time; core has no time zone data, so its strftime formats the UTC
wall-clock time, and a clock that wants local time adds the offset.
Sourcepub fn record(self, value: bool) -> Self
pub fn record(self, value: bool) -> Self
Record what is written (default off), for
Console::export_text_recorded, Console::export_html_recorded
and Console::export_svg_recorded. Port of Console(record=…).
Sourcepub fn environ(self, environ: Environ) -> Self
pub fn environ(self, environ: Environ) -> Self
Detect the terminal from environ instead of the process
environment: NO_COLOR, COLUMNS, LINES, TERM, COLORTERM,
TTY_COMPATIBLE and FORCE_COLOR. Port of Console(_environ=…),
which upstream provides for tests.
Sourcepub fn quiet(self, value: bool) -> Self
pub fn quiet(self, value: bool) -> Self
Suppress all output (default off). Port of Console(quiet=…).
Sourcepub fn soft_wrap(self, value: bool) -> Self
pub fn soft_wrap(self, value: bool) -> Self
The default of print(soft_wrap=…) (default off): no wrapping and
no cropping. Port of Console(soft_wrap=…).
Sourcepub fn style(self, style: impl Into<StyleType>) -> Self
pub fn style(self, style: impl Into<StyleType>) -> Self
A style applied to all output (default none). Port of
Console(style=…).
Sourcepub fn on_broken_pipe(
self,
handler: impl Fn(&Console) + Send + Sync + 'static,
) -> Self
pub fn on_broken_pipe( self, handler: impl Fn(&Console) + Send + Sync + 'static, ) -> Self
Call handler in place of Console::on_broken_pipe’s default
(quiet, then exit with status 1) when a write finds the pipe closed.
Upstream overrides Console.on_broken_pipe in a subclass.
Sourcepub fn markup(self, value: bool) -> Self
pub fn markup(self, value: bool) -> Self
Enable/disable console markup in printed strings (default enabled).
Port of Console(markup=…).
Sourcepub fn emoji_variant(self, variant: Option<EmojiVariant>) -> Self
pub fn emoji_variant(self, variant: Option<EmojiVariant>) -> Self
The emoji variant appended to codes that name none (default none).
Port of Console(emoji_variant=…).
Sourcepub fn tab_size(self, tab_size: usize) -> Self
pub fn tab_size(self, tab_size: usize) -> Self
The tab stop width Text expands tabs to (default 8). Port of
Console(tab_size=…).
pub fn force_terminal(self, value: bool) -> Self
Sourcepub fn legacy_windows(self, value: bool) -> Self
pub fn legacy_windows(self, value: bool) -> Self
Force legacy-Windows-console behavior (box substitution). Default off.
Sourcepub fn safe_box(self, value: bool) -> Self
pub fn safe_box(self, value: bool) -> Self
Enable/disable terminal-safe box substitution (default on).
Sourcepub fn ascii_only(self, value: bool) -> Self
pub fn ascii_only(self, value: bool) -> Self
Force ASCII-only box rendering (default off). Set for non-UTF-8 terminals.
Sourcepub fn color_system(self, system: Option<ColorSystem>) -> Self
pub fn color_system(self, system: Option<ColorSystem>) -> Self
Force a specific color system (use for reproducible output/tests).
pub fn width(self, width: usize) -> Self
Sourcepub fn no_color(self, value: bool) -> Self
pub fn no_color(self, value: bool) -> Self
Enable no-colour mode: colours are stripped from output while other
attributes (bold, underline, …) still render. Unset, a non-empty
NO_COLOR environment variable enables it. Port of no_color=.
Sourcepub fn get_time(self, clock: impl Fn() -> f64 + Send + Sync + 'static) -> Self
pub fn get_time(self, clock: impl Fn() -> f64 + Send + Sync + 'static) -> Self
Read the current time (seconds) from clock instead of the monotonic
clock. Port of Console(get_time=…); animations such as
Spinner render the frame for this time.
Sourcepub fn emoji(self, value: bool) -> Self
pub fn emoji(self, value: bool) -> Self
Enable/disable :emoji: shortcode replacement (default enabled).
Sourcepub fn highlight(self, value: bool) -> Self
pub fn highlight(self, value: bool) -> Self
Enable/disable automatic repr highlighting. Defaults to on, matching
upstream Console(highlight=True).