Skip to content

Commit

Permalink
docs(help): Show how to style text
Browse files Browse the repository at this point in the history
Fixes #3108
Fixes #1433
  • Loading branch information
epage committed Mar 28, 2023
1 parent 5ebcb4c commit b6432c8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
38 changes: 38 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clap_builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ snapbox = "0.4.10"
shlex = "1.1.0"
static_assertions = "1.1.0"
unic-emoji-char = "0.9.0"
color-print = "0.3.4"
20 changes: 18 additions & 2 deletions clap_builder/src/builder/styled_str.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
/// Terminal-styling container
///
/// For now, this is the same as a [`Str`][crate::builder::Str]. This exists to reserve space in
/// the API for exposing terminal styling.
/// Styling may be encoded as [ANSI Escape Code](https://en.wikipedia.org/wiki/ANSI_escape_code)
///
/// # Examples
///
/// ```rust
/// # use clap_builder as clap;
/// // `cstr!` converts tags to ANSI codes
/// let after_help: &'static str = color_print::cstr!(
/// r#"<bold><underline>Examples</underline></bold>
///
/// <dim>$</dim> <bold>mybin --input file.toml</bold>
/// "#);
///
/// let cmd = clap::Command::new("mybin")
/// .after_help(after_help) // The `&str` gets converted into a `StyledStr`
/// // ...
/// # ;
/// ```
#[derive(Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct StyledStr(String);

Expand Down

0 comments on commit b6432c8

Please sign in to comment.