Skip to content

Commit

Permalink
Merge pull request clap-rs#4765 from epage/anstream
Browse files Browse the repository at this point in the history
feat(help): Allow user-provided styled text in `StyledStr`
  • Loading branch information
epage committed Mar 28, 2023
2 parents 2852653 + b6432c8 commit 52eab28
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 269 deletions.
50 changes: 44 additions & 6 deletions Cargo.lock

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

16 changes: 5 additions & 11 deletions clap_builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,13 @@ dependent-version = "upgrade"
tag-name = "v{{version}}"

[features]
default = [
"std",
"color",
"help",
"usage",
"error-context",
"suggestions",
]
default = ["std", "color", "help", "usage", "error-context", "suggestions"]
debug = ["dep:backtrace"] # Enables debug messages
unstable-doc = ["cargo", "wrap_help", "env", "unicode", "string", "unstable-replace"] # for docs.rs

# Used in default
std = [] # support for no_std in a backwards-compatible way
color = ["dep:is-terminal", "dep:termcolor"]
color = ["dep:anstyle", "dep:anstream"]
help = []
usage = []
error-context = []
Expand All @@ -70,8 +63,8 @@ clap_lex = { path = "../clap_lex", version = "0.4.0" }
bitflags = "1.2.0"
unicase = { version = "2.6.0", optional = true }
strsim = { version = "0.10.0", optional = true }
is-terminal = { version = "0.4.1", optional = true }
termcolor = { version = "1.1.1", optional = true }
anstream = { version = "0.2.5", optional = true }
anstyle = { version = "0.3.5", features = ["std"], optional = true }
terminal_size = { version = "0.2.1", optional = true }
backtrace = { version = "0.3.67", optional = true }
unicode-width = { version = "0.1.9", optional = true }
Expand All @@ -87,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"
2 changes: 1 addition & 1 deletion clap_builder/src/builder/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4280,7 +4280,7 @@ impl Arg {
styled.literal("-");
styled.literal(s);
}
styled.extend(self.stylize_arg_suffix(required).into_iter());
styled.push_styled(&self.stylize_arg_suffix(required));
styled
}

Expand Down
4 changes: 1 addition & 3 deletions clap_builder/src/builder/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4673,9 +4673,7 @@ impl Command {

pub(crate) fn write_version_err(&self, use_long: bool) -> StyledStr {
let msg = self._render_version(use_long);
let mut styled = StyledStr::new();
styled.none(msg);
styled
StyledStr::from(msg)
}

pub(crate) fn long_help_exists(&self) -> bool {
Expand Down

0 comments on commit 52eab28

Please sign in to comment.