/// Write command names and descriptions to an output string.
Write command names and descriptions to an output string.
Write command names and descriptions to an output string .
pub fn write_description(out: &mut String, cmd: &CommandInfo<'_>) {
    let mut current_line = INDENT.to_string();
    current_line.push_str(cmd.name);
    if cmd.description.is_empty() {
        new_line(&mut current_line, out);
        return;
    }
    if !indent_description(&mut current_line) {
        // Start the description on a new line if the flag names already
        // add up to more than DESCRIPTION_INDENT.
        new_line(&mut current_line, out);
    }
    let mut words = cmd.description.split(' ').peekable();
    while let Some(first_word) = words.next() {
        indent_description(&mut current_line);
        current_line.push_str(first_word);
        'inner: while let Some(&word) = words.peek() {
            if (char_len(&current_line) + char_len(word) + 1) > WRAP_WIDTH {
                new_line(&mut current_line, out);
                break 'inner;
            } else {
                // advance the iterator
                let _ = words.next();
                current_line.push(' ');
                current_line.push_str(word);
            }
        }
    }
    new_line(&mut current_line, out);
}
pub fn write_description ( out : & mut String , cmd : & CommandInfo < ' _ > ) { let mut current_line = INDENT . to_string ( ) ; current_line . push_str ( cmd . name ) ; if cmd . description . is_empty ( ) { new_line ( & mut current_line , out ) ; return ; } if ! indent_description ( & mut current_line ) { // Start the description on a new line if the flag names already // add up to more than DESCRIPTION_INDENT. new_line ( & mut current_line , out ) ; } let mut words = cmd . description . split ( ' ' ) . peekable ( ) ; while let Some ( first_word ) = words . next ( ) { indent_description ( & mut current_line ) ; current_line . push_str ( first_word ) ; ' inner : while let Some ( & word ) = words . peek ( ) { if ( char_len ( & current_line ) + char_len ( word ) + 1 ) > WRAP_WIDTH { new_line ( & mut current_line , out ) ; break ' inner ; } else { // advance the iterator let _ = words . next ( ) ; current_line . push ( ' ' ) ; current_line . push_str ( word ) ; } } } new_line ( & mut current_line , out ) ; }
Write command names and descriptions to an output string.
Write command names and descriptions to an output string .
out
&mut String
cmd
&CommandInfo<'_>