/// Applies the RTR server command line arguments to a config.
///
/// This functions prints all its error messages directly to stderr.
Applies the RTR server command line arguments to a config.
This functions prints all its error messages directly to stderr.
Applies the RTR server command line arguments to a config . This functions prints all its error messages directly to stderr .
pub fn apply_rtrd_arg_matches(
        &mut self,
        matches: &ArgMatches,
        cur_dir: &Path,
    ) -> Result<(), Error> {
        // refresh
        if let Some(value) = from_str_value_of(matches, "refresh")? {
            self.refresh = Duration::from_secs(value)
        }
        // retry
        if let Some(value) = from_str_value_of(matches, "retry")? {
            self.retry = Duration::from_secs(value)
        }
        // expire
        if let Some(value) = from_str_value_of(matches, "expire")? {
            self.expire = Duration::from_secs(value)
        }
        // history_size
        if let Some(value) = from_str_value_of(matches, "history")? {
            self.history_size = value
        }
        // tcp_listen
        if let Some(list) = matches.values_of("listen") {
            self.tcp_listen = Vec::new();
            for value in list {
                match SocketAddr::from_str(value) {
                    Ok(some) => self.tcp_listen.push(some),
                    Err(_) => {
                        eprintln!("Invalid value for listen: {}", value);
                        return Err(Error);
                    }
                }
            }
        }
        // http_listen
        if let Some(list) = matches.values_of("listen-http") {
            self.http_listen = Vec::new();
            for value in list {
                match SocketAddr::from_str(value) {
                    Ok(some) => self.http_listen.push(some),
                    Err(_) => {
                        eprintln!("Invalid value for listen-http: {}", value);
                        return Err(Error);
                    }
                }
            }
        }
        // pid_file
        if let Some(pid_file) = matches.value_of("pid-file") {
            self.pid_file = Some(cur_dir.join(pid_file))
        }
        // working_dir
        if let Some(working_dir) = matches.value_of("working-dir") {
            self.working_dir = Some(cur_dir.join(working_dir))
        }
        // chroot
        if let Some(chroot) = matches.value_of("chroot") {
            self.chroot = Some(cur_dir.join(chroot))
        }
        Ok(())
    }
pub fn apply_rtrd_arg_matches ( & mut self , matches : & ArgMatches , cur_dir : & Path , ) -> Result < ( ) , Error > { // refresh if let Some ( value ) = from_str_value_of ( matches , " " ) ? { self . refresh = Duration :: from_secs ( value ) } // retry if let Some ( value ) = from_str_value_of ( matches , " " ) ? { self . retry = Duration :: from_secs ( value ) } // expire if let Some ( value ) = from_str_value_of ( matches , " " ) ? { self . expire = Duration :: from_secs ( value ) } // history_size if let Some ( value ) = from_str_value_of ( matches , " " ) ? { self . history_size = value } // tcp_listen if let Some ( list ) = matches . values_of ( " " ) { self . tcp_listen = Vec :: new ( ) ; for value in list { match SocketAddr :: from_str ( value ) { Ok ( some ) => self . tcp_listen . push ( some ) , Err ( _ ) => { eprintln ! ( " " value ) ; return Err ( Error ) ; } } } } // http_listen if let Some ( list ) = matches . values_of ( " " ) { self . http_listen = Vec :: new ( ) ; for value in list { match SocketAddr :: from_str ( value ) { Ok ( some ) => self . http_listen . push ( some ) , Err ( _ ) => { eprintln ! ( " " value ) ; return Err ( Error ) ; } } } } // pid_file if let Some ( pid_file ) = matches . value_of ( " " ) { self . pid_file = Some ( cur_dir . join ( pid_file ) ) } // working_dir if let Some ( working_dir ) = matches . value_of ( " " ) { self . working_dir = Some ( cur_dir . join ( working_dir ) ) } // chroot if let Some ( chroot ) = matches . value_of ( " " ) { self . chroot = Some ( cur_dir . join ( chroot ) ) } Ok ( ( ) ) }
Applies the RTR server command line arguments to a config.
Applies the RTR server command line arguments to a config .
&mut self
matches
&ArgMatches
cur_dir
&Path