cli: do not require RID for sync inventory
The inventory operation of the `rad sync` command does not require an RID. Localise resolving the RID in the match arms that require it. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
ca9d2b44df
commit
ea31040ec6
|
|
@ -298,15 +298,6 @@ impl Args for Options {
|
||||||
|
|
||||||
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
let profile = ctx.profile()?;
|
let profile = ctx.profile()?;
|
||||||
let rid = match options.rid {
|
|
||||||
Some(rid) => rid,
|
|
||||||
None => {
|
|
||||||
let (_, rid) =
|
|
||||||
radicle::rad::cwd().context("Current directory is not a Radicle repository")?;
|
|
||||||
|
|
||||||
rid
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let mut node = radicle::Node::new(profile.socket());
|
let mut node = radicle::Node::new(profile.socket());
|
||||||
if !node.is_running() {
|
if !node.is_running() {
|
||||||
anyhow::bail!(
|
anyhow::bail!(
|
||||||
|
|
@ -316,13 +307,29 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
|
|
||||||
match options.op {
|
match options.op {
|
||||||
Operation::Status => {
|
Operation::Status => {
|
||||||
|
let rid = match options.rid {
|
||||||
|
Some(rid) => rid,
|
||||||
|
None => {
|
||||||
|
let (_, rid) = radicle::rad::cwd()
|
||||||
|
.context("Current directory is not a Radicle repository")?;
|
||||||
|
rid
|
||||||
|
}
|
||||||
|
};
|
||||||
sync_status(rid, &mut node, &profile, &options)?;
|
sync_status(rid, &mut node, &profile, &options)?;
|
||||||
}
|
}
|
||||||
Operation::Synchronize(SyncMode::Repo {
|
Operation::Synchronize(SyncMode::Repo {
|
||||||
settings,
|
settings,
|
||||||
direction,
|
direction,
|
||||||
}) => {
|
}) => {
|
||||||
let settings = settings.with_profile(&profile);
|
let rid = match options.rid {
|
||||||
|
Some(rid) => rid,
|
||||||
|
None => {
|
||||||
|
let (_, rid) = radicle::rad::cwd()
|
||||||
|
.context("Current directory is not a Radicle repository")?;
|
||||||
|
rid
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let settings = settings.clone().with_profile(&profile);
|
||||||
|
|
||||||
if [SyncDirection::Fetch, SyncDirection::Both].contains(&direction) {
|
if [SyncDirection::Fetch, SyncDirection::Both].contains(&direction) {
|
||||||
if !profile.policies()?.is_seeding(&rid)? {
|
if !profile.policies()?.is_seeding(&rid)? {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue