pub(crate) fn write_all_args(&mut self) -> ClapResult<()> {
        debug!("Help::write_all_args");
        let flags = self.parser.has_flags();
        // Strange filter/count vs fold... https://github.com/rust-lang/rust/issues/33038
        let pos = positionals!(self.parser.app).fold(0, |acc, arg| {
            if should_show_arg(self.use_long, arg) {
                acc + 1
            } else {
                acc
            }
        }) > 0;
        let opts = opts!(self.parser.app)
            .filter(|arg| should_show_arg(self.use_long, arg))
            .collect::<Vec<_>>();
        let subcmds = self.parser.has_visible_subcommands();

        let custom_headings = self.parser.app.args.args.iter().fold(0, |acc, arg| {
            if arg.help_heading.is_some() {
                acc + 1
            } else {
                acc
            }
        }) > 0;

        let mut first = if pos {
            self.warning("ARGS:\n")?;
            self.write_args_unsorted(&*positionals!(self.parser.app).collect::<Vec<_>>())?;
            false
        } else {
            true
        };

        let unified_help = self.parser.is_set(AppSettings::UnifiedHelpMessage);

        if unified_help && (flags || !opts.is_empty()) {
            let opts_flags = self
                .parser
                .app
                .args
                .args
                .iter()
                .filter(|a| a.has_switch())
                .collect::<Vec<_>>();
            if !first {
                self.none("\n\n")?;
            }
            self.warning("OPTIONS:\n")?;
            self.write_args(&*opts_flags)?;
            first = false;
        } else {
            if flags {
                if !first {
                    self.none("\n\n")?;
                }
                self.warning("FLAGS:\n")?;
                let flags_v: Vec<_> = flags!(self.parser.app).collect();
                self.write_args(&*flags_v)?;
                first = false;
            }
            if !opts.is_empty() {
                if !first {
                    self.none("\n\n")?;
                }
                self.warning("OPTIONS:\n")?;
                self.write_args(&opts)?;
                first = false;
            }
            if custom_headings {
                for heading in self
                    .parser
                    .app
                    .help_headings
                    .iter()
                    .filter(|heading| heading.is_some())
                    .map(|heading| heading.unwrap())
                {
                    if !first {
                        self.none("\n\n")?;
                    }
                    self.warning(&*format!("{}:\n", heading))?;
                    let args = self
                        .parser
                        .app
                        .args
                        .args
                        .iter()
                        .filter(|a| a.help_heading.is_some() && a.help_heading.unwrap() == heading)
                        .collect::<Vec<_>>();
                    self.write_args(&*args)?;
                    first = false
                }
            }
        }

        if subcmds {
            if !first {
                self.none("\n\n")?;
            }
            self.warning("SUBCOMMANDS:\n")?;
            self.write_subcommands(&self.parser.app)?;
        }

        Ok(())
    }
/// Writes help for all arguments (options, flags, args, subcommands)
/// including titles of a Parser Object to the wrapped stream.
Writes help for all arguments (options, flags, args, subcommands)
including titles of a Parser Object to the wrapped stream.
Writes help for all arguments ( options flags args subcommands ) including titles of a Parser Object to the wrapped stream .
pub(crate) fn write_all_args(&mut self) -> ClapResult<()> {
        debug!("Help::write_all_args");
        let flags = self.parser.has_flags();
        // Strange filter/count vs fold... https://github.com/rust-lang/rust/issues/33038
        let pos = positionals!(self.parser.app).fold(0, |acc, arg| {
            if should_show_arg(self.use_long, arg) {
                acc + 1
            } else {
                acc
            }
        }) > 0;
        let opts = opts!(self.parser.app)
            .filter(|arg| should_show_arg(self.use_long, arg))
            .collect::<Vec<_>>();
        let subcmds = self.parser.has_visible_subcommands();
        let custom_headings = self.parser.app.args.args.iter().fold(0, |acc, arg| {
            if arg.help_heading.is_some() {
                acc + 1
            } else {
                acc
            }
        }) > 0;
        let mut first = if pos {
            self.warning("ARGS:\n")?;
            self.write_args_unsorted(&*positionals!(self.parser.app).collect::<Vec<_>>())?;
            false
        } else {
            true
        };
        let unified_help = self.parser.is_set(AppSettings::UnifiedHelpMessage);
        if unified_help && (flags || !opts.is_empty()) {
            let opts_flags = self
                .parser
                .app
                .args
                .args
                .iter()
                .filter(|a| a.has_switch())
                .collect::<Vec<_>>();
            if !first {
                self.none("\n\n")?;
            }
            self.warning("OPTIONS:\n")?;
            self.write_args(&*opts_flags)?;
            first = false;
        } else {
            if flags {
                if !first {
                    self.none("\n\n")?;
                }
                self.warning("FLAGS:\n")?;
                let flags_v: Vec<_> = flags!(self.parser.app).collect();
                self.write_args(&*flags_v)?;
                first = false;
            }
            if !opts.is_empty() {
                if !first {
                    self.none("\n\n")?;
                }
                self.warning("OPTIONS:\n")?;
                self.write_args(&opts)?;
                first = false;
            }
            if custom_headings {
                for heading in self
                    .parser
                    .app
                    .help_headings
                    .iter()
                    .filter(|heading| heading.is_some())
                    .map(|heading| heading.unwrap())
                {
                    if !first {
                        self.none("\n\n")?;
                    }
                    self.warning(&*format!("{}:\n", heading))?;
                    let args = self
                        .parser
                        .app
                        .args
                        .args
                        .iter()
                        .filter(|a| a.help_heading.is_some() && a.help_heading.unwrap() == heading)
                        .collect::<Vec<_>>();
                    self.write_args(&*args)?;
                    first = false
                }
            }
        }
        if subcmds {
            if !first {
                self.none("\n\n")?;
            }
            self.warning("SUBCOMMANDS:\n")?;
            self.write_subcommands(&self.parser.app)?;
        }
        Ok(())
    }
pub ( crate ) fn write_all_args ( & mut self ) -> ClapResult < ( ) > { debug ! ( " " ) ; let flags = self . parser . has_flags ( ) ; // Strange filter/count vs fold... https://github.com/rust-lang/rust/issues/33038 let pos = positionals ! ( self parser app ) . fold ( 0 , | acc , arg | { if should_show_arg ( self . use_long , arg ) { acc + 1 } else { acc } } ) > 0 ; let opts = opts ! ( self parser app ) . filter ( | arg | should_show_arg ( self . use_long , arg ) ) . collect :: < Vec < _ > > ( ) ; let subcmds = self . parser . has_visible_subcommands ( ) ; let custom_headings = self . parser . app . args . args . iter ( ) . fold ( 0 , | acc , arg | { if arg . help_heading . is_some ( ) { acc + 1 } else { acc } } ) > 0 ; let mut first = if pos { self . warning ( " \n " ) ? ; self . write_args_unsorted ( & * positionals ! ( self parser app ) . collect :: < Vec < _ > > ( ) ) ? ; false } else { true } ; let unified_help = self . parser . is_set ( AppSettings :: UnifiedHelpMessage ) ; if unified_help && ( flags || ! opts . is_empty ( ) ) { let opts_flags = self . parser . app . args . args . iter ( ) . filter ( | a | a . has_switch ( ) ) . collect :: < Vec < _ > > ( ) ; if ! first { self . none ( " \n \n " ) ? ; } self . warning ( " \n " ) ? ; self . write_args ( & * opts_flags ) ? ; first = false ; } else { if flags { if ! first { self . none ( " \n \n " ) ? ; } self . warning ( " \n " ) ? ; let flags_v : Vec < _ > = flags ! ( self parser app ) . collect ( ) ; self . write_args ( & * flags_v ) ? ; first = false ; } if ! opts . is_empty ( ) { if ! first { self . none ( " \n \n " ) ? ; } self . warning ( " \n " ) ? ; self . write_args ( & opts ) ? ; first = false ; } if custom_headings { for heading in self . parser . app . help_headings . iter ( ) . filter ( | heading | heading . is_some ( ) ) . map ( | heading | heading . unwrap ( ) ) { if ! first { self . none ( " \n \n " ) ? ; } self . warning ( & * format ! ( " \n " heading ) ) ? ; let args = self . parser . app . args . args . iter ( ) . filter ( | a | a . help_heading . is_some ( ) && a . help_heading . unwrap ( ) == heading ) . collect :: < Vec < _ > > ( ) ; self . write_args ( & * args ) ? ; first = false } } } if subcmds { if ! first { self . none ( " \n \n " ) ? ; } self . warning ( " \n " ) ? ; self . write_subcommands ( & self . parser . app ) ? ; } Ok ( ( ) ) }
Writes help for all arguments (options, flags, args, subcommands)
including titles of a Parser Object to the wrapped stream.
Writes help for all arguments ( options flags args subcommands ) including titles of a Parser Object to the wrapped stream .
&mut self
&mut self