Skip to content

Commit

Permalink
Merge pull request #151 from QuarticCat/master
Browse files Browse the repository at this point in the history
Beautify help messages
  • Loading branch information
ducaale authored Jun 5, 2021
2 parents 1556032 + b547eb8 commit 95d6fc7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ serde = "1.0"
serde_json = { version = "1.0", features = ["preserve_order"] }
serde_urlencoded = "0.7.0"
shell-escape = "0.1.5"
structopt = "0.3"
structopt = { version = "0.3", features = ["wrap_help"] }
termcolor = "1.1.2"
jsonxf = "1.1.0"

Expand Down
15 changes: 14 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ use crate::{buffer::Buffer, request_items::RequestItem};
///
/// It reimplements as much as possible of HTTPie's excellent design.
#[derive(StructOpt, Debug)]
#[structopt(name = "xh", settings = &[AppSettings::DeriveDisplayOrder, AppSettings::UnifiedHelpMessage])]
#[structopt(
name = "xh",
settings = &[
AppSettings::DeriveDisplayOrder,
AppSettings::UnifiedHelpMessage,
AppSettings::ColoredHelp,
],
)]
pub struct Cli {
/// (default) Serialize data items from the command line as a JSON object.
#[structopt(short = "j", long, overrides_with_all = &["form", "multipart"])]
Expand Down Expand Up @@ -429,6 +436,12 @@ impl Cli {

pub fn clap() -> clap::App<'static, 'static> {
let mut app = <Self as StructOpt>::clap();
// Clap 2.33 implements color output via ansi_term crate,
// which does not handle `NO_COLOR` environment variable.
// We handle it here.
if env::var_os("NO_COLOR").is_some() {
app = app.setting(AppSettings::ColorNever);
}
for &flag in NEGATION_FLAGS {
// `orig` and `flag` both need a static lifetime, so we
// build `orig` by trimming `flag` instead of building `flag`
Expand Down

0 comments on commit 95d6fc7

Please sign in to comment.