Skip to content

Commit

Permalink
chore: rustfmt run
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed Feb 21, 2017
1 parent 8c2dd28 commit 588f373
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
18 changes: 11 additions & 7 deletions src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,21 @@ impl<'a> Help<'a> {
debugln!("Help::write_before_after_help;");
let mut help = String::new();
// determine if our help fits or needs to wrap
debugln!("Help::write_before_after_help: Term width...{}", self.term_w);
debugln!("Help::write_before_after_help: Term width...{}",
self.term_w);
let too_long = str_width(h) >= self.term_w;

debug!("Help::write_before_after_help: Too long...");
if too_long || h.contains("{n}") {
sdebugln!("Yes");
help.push_str(h);
debugln!("Help::write_before_after_help: help: {}", help);
debugln!("Help::write_before_after_help: help width: {}", str_width(&*help));
debugln!("Help::write_before_after_help: help width: {}",
str_width(&*help));
// Determine how many newlines we need to insert
debugln!("Help::write_before_after_help: Usable space: {}", self.term_w);
let longest_w = find_longest!(help);
debugln!("Help::write_before_after_help: Usable space: {}",
self.term_w);
let longest_w = find_longest!(help);
help = help.replace("{n}", "\n");
wrap_help(&mut help, longest_w, self.term_w);
} else {
Expand Down Expand Up @@ -451,7 +454,7 @@ impl<'a> Help<'a> {
// Determine how many newlines we need to insert
let avail_chars = self.term_w - spcs;
debugln!("Help::help: Usable space...{}", avail_chars);
let longest_w = find_longest!(help);
let longest_w = find_longest!(help);
help = help.replace("{n}", "\n");
wrap_help(&mut help, longest_w, avail_chars);
} else {
Expand Down Expand Up @@ -938,7 +941,8 @@ fn wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
debugln!("Help::wrap_help:iter: idx={}, g={}", idx, g);
if g == "\n" {
debugln!("Help::wrap_help:iter: Newline found...");
debugln!("Help::wrap_help:iter: Still space...{:?}", str_width(&help[j..idx]) < avail_chars);
debugln!("Help::wrap_help:iter: Still space...{:?}",
str_width(&help[j..idx]) < avail_chars);
if str_width(&help[j..idx]) < avail_chars {
j = idx;
continue;
Expand All @@ -957,7 +961,7 @@ fn wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
j = prev_space;
debugln!("Help::wrap_help:iter: prev_space={}, j={}", prev_space, j);
debugln!("Help::wrap_help:iter: Removing...{}", j);
debugln!("Help::wrap_help:iter: Char at {}: {:?}", j, &help[j..j+1]);
debugln!("Help::wrap_help:iter: Char at {}: {:?}", j, &help[j..j + 1]);
help.remove(j);
help.insert(j, '\n');
prev_space = idx;
Expand Down
18 changes: 8 additions & 10 deletions src/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ pub struct AppFlags(Flags);

impl BitOr for AppFlags {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
AppFlags(self.0 | rhs.0)
}
fn bitor(self, rhs: Self) -> Self { AppFlags(self.0 | rhs.0) }
}

impl Default for AppFlags {
Expand Down Expand Up @@ -206,7 +204,7 @@ pub enum AppSettings {
///
/// This would otherwise not be allowed. This is useful when `[optional]` has a default value.
///
/// **Note:** In addition to using this setting, the second positional argument *must* be
/// **Note:** In addition to using this setting, the second positional argument *must* be
/// [required]
///
/// # Examples
Expand Down Expand Up @@ -267,9 +265,9 @@ pub enum AppSettings {
AllowExternalSubcommands,

/// Specifies that use of a valid [argument] negates [subcomands] being used after. By default
/// `clap` allows arguments between subcommands such as
/// `<cmd> [cmd_args] <cmd2> [cmd2_args] <cmd3> [cmd3_args]`. This setting disables that
/// functionality and says that arguments can only follow the *final* subcommand. For instance
/// `clap` allows arguments between subcommands such as
/// `<cmd> [cmd_args] <cmd2> [cmd2_args] <cmd3> [cmd3_args]`. This setting disables that
/// functionality and says that arguments can only follow the *final* subcommand. For instance
/// using this setting makes only the following invocations possible:
///
/// * `<cmd> <cmd2> <cmd3> [cmd3_args]`
Expand All @@ -294,7 +292,7 @@ pub enum AppSettings {
/// **NOTE:** [`SubCommand`]s count as arguments
///
/// **NOTE:** Setting [`Arg::default_value`] effectively disables this option as it will
/// ensure that some argument is always present.
/// ensure that some argument is always present.
///
/// # Examples
///
Expand Down Expand Up @@ -413,7 +411,7 @@ pub enum AppSettings {
/// [`Arg::use_delimiter(false)`]: ./struct.Arg.html#method.use_delimiter
DontDelimitTrailingValues,

/// Disables the `help` subcommand
/// Disables the `help` subcommand
///
/// # Examples
///
Expand All @@ -424,7 +422,7 @@ pub enum AppSettings {
/// .setting(AppSettings::DisableHelpSubcommand)
/// // Normally, creating a subcommand causes a `help` subcommand to automaticaly
/// // be generated as well
/// .subcommand(SubCommand::with_name("test"))
/// .subcommand(SubCommand::with_name("test"))
/// .get_matches_from_safe(vec![
/// "myprog", "help"
/// ]);
Expand Down

0 comments on commit 588f373

Please sign in to comment.