| |
Repo(RepoId),
|
| |
}
|
| |
|
| - |
#[derive(Debug, Error)]
|
| - |
#[error("invalid repository or node specified (RID parsing failed with: '{repo}', NID parsing failed with: '{node}'))")]
|
| - |
pub(super) struct ParseTargetError {
|
| - |
repo: radicle::identity::IdError,
|
| - |
node: radicle::crypto::PublicKeyError,
|
| - |
}
|
| - |
|
| - |
impl std::str::FromStr for Target {
|
| - |
type Err = ParseTargetError;
|
| - |
|
| - |
fn from_str(val: &str) -> Result<Self, Self::Err> {
|
| - |
val.parse::<RepoId>().map(Target::Repo).or_else(|repo| {
|
| - |
val.parse::<NodeId>()
|
| - |
.map(Target::Node)
|
| - |
.map_err(|node| ParseTargetError { repo, node })
|
| - |
})
|
| - |
}
|
| - |
}
|
| - |
|
| |
impl std::fmt::Display for Target {
|
| |
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
| |
match self {
|
| |
}
|
| |
}
|
| |
|
| + |
#[derive(Debug, Error)]
|
| + |
#[error("could not parse value as Repository ID or Node ID")]
|
| + |
pub(super) struct ParseTargetError {}
|
| + |
|
| + |
fn parse_target(value: &str) -> Result<Target, ParseTargetError> {
|
| + |
value.parse::<RepoId>().map(Target::Repo).or(value
|
| + |
.parse::<NodeId>()
|
| + |
.map(Target::Node)
|
| + |
.map_err(|_| ParseTargetError {}))
|
| + |
}
|
| + |
|
| |
#[derive(Parser, Debug)]
|
| |
#[command(about = ABOUT, disable_version_flag = true)]
|
| |
pub struct Args {
|
| |
/// A Repository ID or Node ID to block from seeding or following (respectively)
|
| - |
#[arg(value_name = "RID|NID")]
|
| + |
///
|
| + |
/// Example values:
|
| + |
/// - z6MksmpU5b1dS7oaqF2bHXhQi1DWy2hB7Mh9CuN7y1DN6QSz (Node ID)
|
| + |
/// - rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 (Repository ID)
|
| + |
#[arg(value_name = "RID|NID", value_parser = parse_target, verbatim_doc_comment)]
|
| |
pub(super) target: Target,
|
| |
}
|