/// Creates a command from clap matches.
///
/// This function prints errors to stderr.
Creates a command from clap matches.
This function prints errors to stderr.
Creates a command from clap matches . This function prints errors to stderr .
pub fn from_arg_matches(
        matches: &ArgMatches,
        cur_dir: &Path,
        config: &mut Config
    ) -> Result<Self, Error> {
        Ok(match matches.subcommand() {
            ("config", Some(matches)) => {
                config.apply_rtrd_arg_matches(matches, cur_dir)?;
                Operation::Config
            }
            ("man", Some(matches)) => {
                Operation::Man {
                    output: matches.value_of("output").map(|value| {
                        match value {
                            "-" => None,
                            path => Some(path.into())
                        }
                    })
                }
            }
            ("rtrd", Some(matches)) => {
                config.apply_rtrd_arg_matches(matches, cur_dir)?;
                Operation::Rtrd {
                    attached: matches.is_present("attached")
                }
            }
            ("update", _) => Operation::Update,
            ("vrps", Some(matches)) => {
                Operation::Vrps {
                    output: match matches.value_of("output").unwrap() {
                        "-" => None,
                        path => Some(path.into())
                    },
                    format: match matches.value_of("format").unwrap() {
                        "csv" => OutputFormat::Csv,
                        "csvext" => OutputFormat::ExtendedCsv,
                        "json" => OutputFormat::Json,
                        "openbgpd" => OutputFormat::Openbgpd,
                        "rpsl" => OutputFormat::Rpsl,
                        "none" => OutputFormat::None,
                        _ => panic!("unexpected format argument")
                    },
                    noupdate: matches.is_present("noupdate")
                }
            }
            ("", _) => {
                eprintln!(
                    "Error: a command is required.\n\
                     \nCommonly used commands are:\
                     \n   vrps   produces a list of validated ROA payload\
                     \n   rtrd   start the RTR server\
                     \n   man    show the manual page\
                     \n\
                     \nSee routinator -h for a usage summary or\
                       routinator man for detailed help."
                );
                return Err(Error)
            }
            _ => panic!("Unexpected subcommand."),
        })
    }
pub fn from_arg_matches ( matches : & ArgMatches , cur_dir : & Path , config : & mut Config ) -> Result < Self , Error > { Ok ( match matches . subcommand ( ) { ( " " , Some ( matches ) ) => { config . apply_rtrd_arg_matches ( matches , cur_dir ) ? ; Operation :: Config } ( " " , Some ( matches ) ) => { Operation :: Man { output : matches . value_of ( " " ) . map ( | value | { match value { " " => None , path => Some ( path . into ( ) ) } } ) } } ( " " , Some ( matches ) ) => { config . apply_rtrd_arg_matches ( matches , cur_dir ) ? ; Operation :: Rtrd { attached : matches . is_present ( " " ) } } ( " " , _ ) => Operation :: Update , ( " " , Some ( matches ) ) => { Operation :: Vrps { output : match matches . value_of ( " " ) . unwrap ( ) { " " => None , path => Some ( path . into ( ) ) } , format : match matches . value_of ( " " ) . unwrap ( ) { " " => OutputFormat :: Csv , " " => OutputFormat :: ExtendedCsv , " " => OutputFormat :: Json , " " => OutputFormat :: Openbgpd , " " => OutputFormat :: Rpsl , " " => OutputFormat :: None , _ => panic ! ( " " ) } , noupdate : matches . is_present ( " " ) } } ( " " , _ ) => { eprintln ! ( " \n \
 \n \
 \n \
 \n \
 \n \
 \n \
 \n \
 " ) ; return Err ( Error ) } _ => panic ! ( " " ) , } ) }
Creates a command from clap matches.
Creates a command from clap matches .
matches
&ArgMatches
cur_dir
&Path
config
&mut Config