pub struct Printer<W: RawStream> { /* private fields */ }Expand description
Wrapper around an I/O writer. Will style the output with ANSI sequences if appropriate.
Internally, the printer is based on anstream / anstyle; see their docs to find out how styling support
is detected by default. (TL;DR: based on NO_COLOR, CLICOLOR_FORCE and CLICOLOR env vars, and whether
the output is a terminal.) If this detection doesn’t work for you, you can always create a fully custom Printer.
Implementations§
Source§impl<W: RawStream + AsLockedWrite> Printer<W>
impl<W: RawStream + AsLockedWrite> Printer<W>
Sourcepub fn print_debug(
self,
repo: &ConfigRepository<'_>,
filter: impl FnMut(ParamRef<'_>) -> bool,
) -> Result<Result<(), ParseErrors>>
pub fn print_debug( self, repo: &ConfigRepository<'_>, filter: impl FnMut(ParamRef<'_>) -> bool, ) -> Result<Result<(), ParseErrors>>
Prints debug info for all param values in the provided repo. If params fail to deserialize,
corresponding error(s) are output as well.
§Errors
- Propagates I/O errors.
- Returns the exhaustive parsing result. Depending on the application, some parsing errors (e.g., missing params for optional configs) may not be fatal.
Source§impl<W: RawStream + AsLockedWrite> Printer<W>
impl<W: RawStream + AsLockedWrite> Printer<W>
Sourcepub fn print_help(
self,
schema: &ConfigSchema,
filter: impl FnMut(ParamRef<'_>) -> bool,
) -> Result<()>
pub fn print_help( self, schema: &ConfigSchema, filter: impl FnMut(ParamRef<'_>) -> bool, ) -> Result<()>
Prints help on config params in the provided schema. Params can be filtered by the supplied predicate.
§Errors
Propagates I/O errors.
Source§impl<W: RawStream + AsLockedWrite> Printer<W>
impl<W: RawStream + AsLockedWrite> Printer<W>
Sourcepub fn print_markdown_reference(
self,
schema: &ConfigSchema,
options: &MarkdownOptions,
filter: impl FnMut(ParamRef<'_>) -> bool,
) -> Result<()>
pub fn print_markdown_reference( self, schema: &ConfigSchema, options: &MarkdownOptions, filter: impl FnMut(ParamRef<'_>) -> bool, ) -> Result<()>
Prints a Markdown reference for config params in the provided schema.
Params can be filtered by the supplied predicate. Enum tag params are rendered together with other matching params in the same config so that conditional fields have useful context.
§Errors
Propagates I/O errors.