fn val(&mut self, arg: &Arg<'c>) -> Result<String, io::Error> {
        debug!("Help::val: arg={}", arg.name);
        let mult =
            arg.is_set(ArgSettings::MultipleValues) || arg.is_set(ArgSettings::MultipleOccurrences);
        if arg.is_set(ArgSettings::TakesValue) || arg.index.is_some() {
            let delim = if arg.is_set(ArgSettings::RequireDelimiter) {
                arg.val_delim.expect(INTERNAL_ERROR_MSG)
            } else {
                ' '
            };
            if let Some(ref vec) = arg.val_names {
                let mut it = vec.iter().peekable();
                while let Some((_, val)) = it.next() {
                    self.good(&format!("<{}>", val))?;
                    if it.peek().is_some() {
                        self.none(&delim.to_string())?;
                    }
                }
                let num = vec.len();
                if mult && num == 1 {
                    self.good("...")?;
                }
            } else if let Some(num) = arg.num_vals {
                let mut it = (0..num).peekable();
                while let Some(_) = it.next() {
                    self.good(&format!("<{}>", arg.name))?;
                    if it.peek().is_some() {
                        self.none(&delim.to_string())?;
                    }
                }
                if mult && num == 1 {
                    self.good("...")?;
                }
            } else if arg.has_switch() {
                self.good(&format!("<{}>", arg.name))?;
                if mult {
                    self.good("...")?;
                }
            } else {
                self.good(&arg.to_string())?;
            }
        }

        let spec_vals = self.spec_vals(arg);
        let h = arg.help.unwrap_or("");
        let h_w = str_width(h) + str_width(&*spec_vals);
        let nlh = self.next_line_help || arg.is_set(ArgSettings::NextLineHelp);
        let taken = self.longest + 12;
        self.force_next_line = !nlh
            && self.term_w >= taken
            && (taken as f32 / self.term_w as f32) > 0.40
            && h_w > (self.term_w - taken);

        debug!("Help::val: Has switch...");
        if arg.has_switch() {
            debug!("Yes");
            debug!("Help::val: force_next_line...{:?}", self.force_next_line);
            debug!("Help::val: nlh...{:?}", nlh);
            debug!("Help::val: taken...{}", taken);
            debug!(
                "val: help_width > (width - taken)...{} > ({} - {})",
                h_w, self.term_w, taken
            );
            debug!("Help::val: longest...{}", self.longest);
            debug!("Help::val: next_line...");
            if !(nlh || self.force_next_line) {
                debug!("No");
                let self_len = str_width(arg.to_string().as_str());
                // subtract ourself
                let mut spcs = self.longest - self_len;
                // Since we're writing spaces from the tab point we first need to know if we
                // had a long and short, or just short
                if arg.long.is_some() {
                    // Only account 4 after the val
                    spcs += 4;
                } else {
                    // Only account for ', --' + 4 after the val
                    spcs += 8;
                }

                write_nspaces!(self, spcs);
            } else {
                debug!("Yes");
            }
        } else if !(nlh || self.force_next_line) {
            debug!("No, and not next_line");
            write_nspaces!(
                self,
                self.longest + 4 - (str_width(arg.to_string().as_str()))
            );
        } else {
            debug!("No");
        }
        Ok(spec_vals)
    }
/// Writes argument's possible values to the wrapped stream.
Writes argument's possible values to the wrapped stream.
Writes argument ' s possible values to the wrapped stream .
fn val(&mut self, arg: &Arg<'c>) -> Result<String, io::Error> {
        debug!("Help::val: arg={}", arg.name);
        let mult =
            arg.is_set(ArgSettings::MultipleValues) || arg.is_set(ArgSettings::MultipleOccurrences);
        if arg.is_set(ArgSettings::TakesValue) || arg.index.is_some() {
            let delim = if arg.is_set(ArgSettings::RequireDelimiter) {
                arg.val_delim.expect(INTERNAL_ERROR_MSG)
            } else {
                ' '
            };
            if let Some(ref vec) = arg.val_names {
                let mut it = vec.iter().peekable();
                while let Some((_, val)) = it.next() {
                    self.good(&format!("<{}>", val))?;
                    if it.peek().is_some() {
                        self.none(&delim.to_string())?;
                    }
                }
                let num = vec.len();
                if mult && num == 1 {
                    self.good("...")?;
                }
            } else if let Some(num) = arg.num_vals {
                let mut it = (0..num).peekable();
                while let Some(_) = it.next() {
                    self.good(&format!("<{}>", arg.name))?;
                    if it.peek().is_some() {
                        self.none(&delim.to_string())?;
                    }
                }
                if mult && num == 1 {
                    self.good("...")?;
                }
            } else if arg.has_switch() {
                self.good(&format!("<{}>", arg.name))?;
                if mult {
                    self.good("...")?;
                }
            } else {
                self.good(&arg.to_string())?;
            }
        }
        let spec_vals = self.spec_vals(arg);
        let h = arg.help.unwrap_or("");
        let h_w = str_width(h) + str_width(&*spec_vals);
        let nlh = self.next_line_help || arg.is_set(ArgSettings::NextLineHelp);
        let taken = self.longest + 12;
        self.force_next_line = !nlh
            && self.term_w >= taken
            && (taken as f32 / self.term_w as f32) > 0.40
            && h_w > (self.term_w - taken);
        debug!("Help::val: Has switch...");
        if arg.has_switch() {
            debug!("Yes");
            debug!("Help::val: force_next_line...{:?}", self.force_next_line);
            debug!("Help::val: nlh...{:?}", nlh);
            debug!("Help::val: taken...{}", taken);
            debug!(
                "val: help_width > (width - taken)...{} > ({} - {})",
                h_w, self.term_w, taken
            );
            debug!("Help::val: longest...{}", self.longest);
            debug!("Help::val: next_line...");
            if !(nlh || self.force_next_line) {
                debug!("No");
                let self_len = str_width(arg.to_string().as_str());
                // subtract ourself
                let mut spcs = self.longest - self_len;
                // Since we're writing spaces from the tab point we first need to know if we
                // had a long and short, or just short
                if arg.long.is_some() {
                    // Only account 4 after the val
                    spcs += 4;
                } else {
                    // Only account for ', --' + 4 after the val
                    spcs += 8;
                }
                write_nspaces!(self, spcs);
            } else {
                debug!("Yes");
            }
        } else if !(nlh || self.force_next_line) {
            debug!("No, and not next_line");
            write_nspaces!(
                self,
                self.longest + 4 - (str_width(arg.to_string().as_str()))
            );
        } else {
            debug!("No");
        }
        Ok(spec_vals)
    }
fn val ( & mut self , arg : & Arg < ' c > ) -> Result < String , io :: Error > { debug ! ( " " arg name ) ; let mult = arg . is_set ( ArgSettings :: MultipleValues ) || arg . is_set ( ArgSettings :: MultipleOccurrences ) ; if arg . is_set ( ArgSettings :: TakesValue ) || arg . index . is_some ( ) { let delim = if arg . is_set ( ArgSettings :: RequireDelimiter ) { arg . val_delim . expect ( INTERNAL_ERROR_MSG ) } else { ' ' } ; if let Some ( ref vec ) = arg . val_names { let mut it = vec . iter ( ) . peekable ( ) ; while let Some ( ( _ , val ) ) = it . next ( ) { self . good ( & format ! ( " " val ) ) ? ; if it . peek ( ) . is_some ( ) { self . none ( & delim . to_string ( ) ) ? ; } } let num = vec . len ( ) ; if mult && num == 1 { self . good ( " " ) ? ; } } else if let Some ( num ) = arg . num_vals { let mut it = ( 0 .. num ) . peekable ( ) ; while let Some ( _ ) = it . next ( ) { self . good ( & format ! ( " " arg name ) ) ? ; if it . peek ( ) . is_some ( ) { self . none ( & delim . to_string ( ) ) ? ; } } if mult && num == 1 { self . good ( " " ) ? ; } } else if arg . has_switch ( ) { self . good ( & format ! ( " " arg name ) ) ? ; if mult { self . good ( " " ) ? ; } } else { self . good ( & arg . to_string ( ) ) ? ; } } let spec_vals = self . spec_vals ( arg ) ; let h = arg . help . unwrap_or ( " " ) ; let h_w = str_width ( h ) + str_width ( & * spec_vals ) ; let nlh = self . next_line_help || arg . is_set ( ArgSettings :: NextLineHelp ) ; let taken = self . longest + 12 ; self . force_next_line = ! nlh && self . term_w >= taken && ( taken as f32 / self . term_w as f32 ) > 0.40 && h_w > ( self . term_w - taken ) ; debug ! ( " " ) ; if arg . has_switch ( ) { debug ! ( " " ) ; debug ! ( " " self force_next_line ) ; debug ! ( " " nlh ) ; debug ! ( " " taken ) ; debug ! ( " " h_w self term_w taken ) ; debug ! ( " " self longest ) ; debug ! ( " " ) ; if ! ( nlh || self . force_next_line ) { debug ! ( " " ) ; let self_len = str_width ( arg . to_string ( ) . as_str ( ) ) ; // subtract ourself let mut spcs = self . longest - self_len ; // Since we're writing spaces from the tab point we first need to know if we // had a long and short, or just short if arg . long . is_some ( ) { // Only account 4 after the val spcs += 4 ; } else { // Only account for ', --' + 4 after the val spcs += 8 ; } write_nspaces ! ( self spcs ) ; } else { debug ! ( " " ) ; } } else if ! ( nlh || self . force_next_line ) { debug ! ( " " ) ; write_nspaces ! ( self self longest 4 ( str_width ( arg to_string ( ) as_str ( ) ) ) ) ; } else { debug ! ( " " ) ; } Ok ( spec_vals ) }
Writes argument's possible values to the wrapped stream.
Writes argument ' s possible values to the wrapped stream .
&mut self
arg
&Arg<'c>
&mut self
arg
&Arg<'c>