fn document(&self, name: &str) -> String {
        let mut msgs = Vec::new();
        // Get the user-given docs (if they exist)
        let doc = match &self.description {
            Some(desc) => desc.to_string(),
            None => String::from("no 'desc' property set"),
        };

        // Set up the left side (command name and some arguments info)
        let mut left = String::new();
        // Environment variables (before the command name)
        for env_var in &self.env_vars {
            left += &format!("<{}> ", env_var);
        }
        // Command name
        left += name;
        // Arguments (after the command name)
        for arg in &self.args {
            left += &format!(" <{}>", arg);
        }
        // Ordered or not
        if self.order.is_some() {
            left += " (ordered)";
        }
        // TODO handle '%%' as `[...]`
        // That's a placeholder for a number of tabs that spaces everything evenly
        msgs.push(format!("{}{{TABS}}{}", left, doc));

        // Loop through every subcommand and document it
        if let Some(subcommands_map) = &self.subcommands {
            // Sort the subcommands alphabetically
            let mut subcommands_iter: Vec<(&String, &Command)> = subcommands_map.iter().collect();
            subcommands_iter.sort_by(|(name, _), (name2, _)| name.cmp(name2));
            for (cmd_name, cmd) in subcommands_iter {
                let subcmd_doc = cmd.document(cmd_name);
                msgs.push(
                    // We add four spaces in front of every line (that way it works recursively for nested subcommands)
                    format!("    {}", subcmd_doc.replace("\n", "\n    ")),
                );
            }
        }

        msgs.join("\n")
    }
// Gets a documentation message for this command based on its metadata and the `desc` properties
Gets a documentation message for this command based on its metadata and the `desc` properties
Gets a documentation message for this command based on its metadata and the ` desc ` properties
fn document(&self, name: &str) -> String {
        let mut msgs = Vec::new();
        // Get the user-given docs (if they exist)
        let doc = match &self.description {
            Some(desc) => desc.to_string(),
            None => String::from("no 'desc' property set"),
        };
        // Set up the left side (command name and some arguments info)
        let mut left = String::new();
        // Environment variables (before the command name)
        for env_var in &self.env_vars {
            left += &format!("<{}> ", env_var);
        }
        // Command name
        left += name;
        // Arguments (after the command name)
        for arg in &self.args {
            left += &format!(" <{}>", arg);
        }
        // Ordered or not
        if self.order.is_some() {
            left += " (ordered)";
        }
        // TODO handle '%%' as `[...]`
        // That's a placeholder for a number of tabs that spaces everything evenly
        msgs.push(format!("{}{{TABS}}{}", left, doc));
        // Loop through every subcommand and document it
        if let Some(subcommands_map) = &self.subcommands {
            // Sort the subcommands alphabetically
            let mut subcommands_iter: Vec<(&String, &Command)> = subcommands_map.iter().collect();
            subcommands_iter.sort_by(|(name, _), (name2, _)| name.cmp(name2));
            for (cmd_name, cmd) in subcommands_iter {
                let subcmd_doc = cmd.document(cmd_name);
                msgs.push(
                    // We add four spaces in front of every line (that way it works recursively for nested subcommands)
                    format!("    {}", subcmd_doc.replace("\n", "\n    ")),
                );
            }
        }
        msgs.join("\n")
    }
fn document ( & self , name : & str ) -> String { let mut msgs = Vec :: new ( ) ; // Get the user-given docs (if they exist) let doc = match & self . description { Some ( desc ) => desc . to_string ( ) , None => String :: from ( " " ) , } ; // Set up the left side (command name and some arguments info) let mut left = String :: new ( ) ; // Environment variables (before the command name) for env_var in & self . env_vars { left += & format ! ( " " env_var ) ; } // Command name left += name ; // Arguments (after the command name) for arg in & self . args { left += & format ! ( " " arg ) ; } // Ordered or not if self . order . is_some ( ) { left += " " ; } // TODO handle '%%' as `[...]` // That's a placeholder for a number of tabs that spaces everything evenly msgs . push ( format ! ( " " left doc ) ) ; // Loop through every subcommand and document it if let Some ( subcommands_map ) = & self . subcommands { // Sort the subcommands alphabetically let mut subcommands_iter : Vec < ( & String , & Command ) > = subcommands_map . iter ( ) . collect ( ) ; subcommands_iter . sort_by ( | ( name , _ ) , ( name2 , _ ) | name . cmp ( name2 ) ) ; for ( cmd_name , cmd ) in subcommands_iter { let subcmd_doc = cmd . document ( cmd_name ) ; msgs . push ( // We add four spaces in front of every line (that way it works recursively for nested subcommands) format ! ( " " subcmd_doc replace ( " \n " " \n " ) ) , ) ; } } msgs . join ( " \n " ) }
Gets a documentation message for this command based on its metadata and the `desc` properties
Gets a documentation message for this command based on its metadata and the ` desc ` properties
&self
name
&str