Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
cli/init: Deduplicate `ScopeParser`
Merged lorenz opened 14 days ago
1 file changed +2 -27 f8ec40a3 2d20e249
modified crates/radicle-cli/src/commands/init/args.rs
@@ -8,6 +8,8 @@ use radicle::{
};
use radicle_term::Interactive;

+
use crate::terminal::args::ScopeParser;
+

const ABOUT: &str = "Initialize a Radicle repository";

#[derive(Debug, Parser)]
@@ -85,33 +87,6 @@ impl Args {
    }
}

-
// TODO(finto): this is duplicated from `clone::args`. Consolidate these once
-
// the `clap` migration has finished and we can organise the shared code.
-
#[derive(Clone, Debug)]
-
struct ScopeParser;
-

-
impl clap::builder::TypedValueParser for ScopeParser {
-
    type Value = Scope;
-

-
    fn parse_ref(
-
        &self,
-
        cmd: &clap::Command,
-
        arg: Option<&clap::Arg>,
-
        value: &std::ffi::OsStr,
-
    ) -> Result<Self::Value, clap::Error> {
-
        <Scope as std::str::FromStr>::from_str.parse_ref(cmd, arg, value)
-
    }
-

-
    fn possible_values(
-
        &self,
-
    ) -> Option<Box<dyn Iterator<Item = clap::builder::PossibleValue> + '_>> {
-
        use clap::builder::PossibleValue;
-
        Some(Box::new(
-
            [PossibleValue::new("all"), PossibleValue::new("followed")].into_iter(),
-
        ))
-
    }
-
}
-

#[cfg(test)]
mod test {
    use super::Args;