pub fn parse_sub(mut args: Args) -> Result<String, ParseSubError> {
    let default_sub = if let Ok(sub) = env::var("POSTMAN_DEFAULT_SUB") {
        sub
    } else {
        return Err(ParseSubError::NoDefaultSub);
    };

    let sub = args.single::<String>().unwrap_or(default_sub);

    if !SUB_REGEX.is_match(&sub) {
        Err(ParseSubError::InvalidSub)
    } else {
        Ok(sub)
    }
}
// parses command arguments and returns a subreddit name
parses command arguments and returns a subreddit name
parses command arguments and returns a subreddit name
pub fn parse_sub(mut args: Args) -> Result<String, ParseSubError> {
    let default_sub = if let Ok(sub) = env::var("POSTMAN_DEFAULT_SUB") {
        sub
    } else {
        return Err(ParseSubError::NoDefaultSub);
    };
    let sub = args.single::<String>().unwrap_or(default_sub);
    if !SUB_REGEX.is_match(&sub) {
        Err(ParseSubError::InvalidSub)
    } else {
        Ok(sub)
    }
}
pub fn parse_sub ( mut args : Args ) -> Result < String , ParseSubError > { let default_sub = if let Ok ( sub ) = env :: var ( " " ) { sub } else { return Err ( ParseSubError :: NoDefaultSub ) ; } ; let sub = args . single :: < String > ( ) . unwrap_or ( default_sub ) ; if ! SUB_REGEX . is_match ( & sub ) { Err ( ParseSubError :: InvalidSub ) } else { Ok ( sub ) } }
parses command arguments and returns a subreddit name
parses command arguments and returns a subreddit name
args
Args