aboutsummaryrefslogtreecommitdiff
path: root/arg_picker/src/builtin/pick_pathbuf.rs
blob: 3bd441047e242f24f0315967a35e83d1683e55a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::path::PathBuf;

use crate::{
    PickerArgResult::{NotFound, Parsed},
    SinglePickable,
};

impl SinglePickable for PathBuf {
    fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> {
        match str {
            Some(str) => match just_fmt::fmt_path_str(str) {
                Ok(formated) => Parsed(PathBuf::from(formated)),
                Err(_) => NotFound,
            },
            None => NotFound,
        }
    }
}