diff --git a/radicle-cli/src/commands/auth.rs b/radicle-cli/src/commands/auth.rs index 57441bb7..c953b518 100644 --- a/radicle-cli/src/commands/auth.rs +++ b/radicle-cli/src/commands/auth.rs @@ -61,7 +61,7 @@ impl Args for Options { pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { match ctx.profile() { - Ok(profile) => authenticate(&profile, options), + Ok(profile) => authenticate(options, &profile), Err(_) => init(options), } } @@ -121,7 +121,7 @@ pub fn init(options: Options) -> anyhow::Result<()> { /// Try loading the identity's key into SSH Agent, falling back to verifying `RAD_PASSPHRASE` for /// use. -pub fn authenticate(profile: &Profile, options: Options) -> anyhow::Result<()> { +pub fn authenticate(options: Options, profile: &Profile) -> anyhow::Result<()> { // Authenticate with SSH Agent only if it is running. match ssh::agent::Agent::connect() { Ok(mut agent) => { diff --git a/radicle-cli/src/commands/clone.rs b/radicle-cli/src/commands/clone.rs index 875fde63..92d837c9 100644 --- a/radicle-cli/src/commands/clone.rs +++ b/radicle-cli/src/commands/clone.rs @@ -103,10 +103,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let mut node = radicle::Node::new(profile.socket()); let (working, doc, proj) = clone( options.id, + options.announce, + &mut node, &signer, &profile.storage, - &mut node, - options.announce, )?; let delegates = doc .delegates @@ -161,10 +161,10 @@ pub enum CloneError { pub fn clone( id: Id, + announce: bool, + node: &mut Node, signer: &G, storage: &Storage, - node: &mut Node, - announce: bool, ) -> Result<(raw::Repository, Doc, Project), CloneError> { let me = *signer.public_key(); diff --git a/radicle-cli/src/commands/delegate.rs b/radicle-cli/src/commands/delegate.rs index 9adcf0a2..8438b360 100644 --- a/radicle-cli/src/commands/delegate.rs +++ b/radicle-cli/src/commands/delegate.rs @@ -115,9 +115,9 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let storage = &profile.storage; match options.op { - Operation::Add { id, did } => add::run(&profile, storage, get_id(id)?, *did)?, - Operation::Remove { id, did } => remove::run(&profile, storage, get_id(id)?, &did)?, - Operation::List { id } => list::run(&profile, storage, get_id(id)?)?, + Operation::Add { id, did } => add::run(get_id(id)?, *did, &profile, storage)?, + Operation::Remove { id, did } => remove::run(get_id(id)?, &did, &profile, storage)?, + Operation::List { id } => list::run(get_id(id)?, &profile, storage)?, } Ok(()) diff --git a/radicle-cli/src/commands/delegate/add.rs b/radicle-cli/src/commands/delegate/add.rs index 6c62b9f7..a3624e5c 100644 --- a/radicle-cli/src/commands/delegate/add.rs +++ b/radicle-cli/src/commands/delegate/add.rs @@ -9,7 +9,7 @@ use radicle_crypto::PublicKey; use crate::terminal as term; -pub fn run(profile: &Profile, storage: &S, id: Id, key: PublicKey) -> anyhow::Result<()> +pub fn run(id: Id, key: PublicKey, profile: &Profile, storage: &S) -> anyhow::Result<()> where S: WriteStorage, { diff --git a/radicle-cli/src/commands/delegate/list.rs b/radicle-cli/src/commands/delegate/list.rs index 01c2b6db..940965f4 100644 --- a/radicle-cli/src/commands/delegate/list.rs +++ b/radicle-cli/src/commands/delegate/list.rs @@ -4,7 +4,7 @@ use radicle::{prelude::Id, storage::ReadStorage, Profile}; use crate::terminal as term; -pub fn run(profile: &Profile, storage: &S, id: Id) -> anyhow::Result<()> +pub fn run(id: Id, profile: &Profile, storage: &S) -> anyhow::Result<()> where S: ReadStorage, { diff --git a/radicle-cli/src/commands/delegate/remove.rs b/radicle-cli/src/commands/delegate/remove.rs index 326b99c3..f45c398e 100644 --- a/radicle-cli/src/commands/delegate/remove.rs +++ b/radicle-cli/src/commands/delegate/remove.rs @@ -9,7 +9,7 @@ use radicle_crypto::PublicKey; use crate::terminal as term; -pub fn run(profile: &Profile, storage: &S, id: Id, key: &PublicKey) -> anyhow::Result<()> +pub fn run(id: Id, key: &PublicKey, profile: &Profile, storage: &S) -> anyhow::Result<()> where S: WriteStorage, { diff --git a/radicle-cli/src/commands/issue.rs b/radicle-cli/src/commands/issue.rs index 48c3ee36..324e362d 100644 --- a/radicle-cli/src/commands/issue.rs +++ b/radicle-cli/src/commands/issue.rs @@ -297,16 +297,16 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { ref tags, } => { open( - &mut issues, - &signer, - &options, title.clone(), description.clone(), tags.to_vec(), + &options, + &mut issues, + &signer, )?; } Operation::List { assigned } => { - list(&issues, &profile, &assigned)?; + list(&issues, &assigned, &profile)?; } Operation::Delete { id } => { let id = id.resolve(&repo.backend)?; @@ -329,8 +329,8 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { fn list( issues: &Issues, - profile: &profile::Profile, assigned: &Option, + profile: &profile::Profile, ) -> anyhow::Result<()> { let me = *profile.id(); @@ -484,12 +484,12 @@ fn prompt_issue( } fn open( - issues: &mut Issues, - signer: &G, - options: &Options, title: Option, description: Option, tags: Vec, + options: &Options, + issues: &mut Issues, + signer: &G, ) -> anyhow::Result<()> { let Some((meta, description)) = prompt_issue( &title.unwrap_or_default(), diff --git a/radicle-cli/src/commands/patch.rs b/radicle-cli/src/commands/patch.rs index 287d81ab..cd37c287 100644 --- a/radicle-cli/src/commands/patch.rs +++ b/radicle-cli/src/commands/patch.rs @@ -364,21 +364,21 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { quiet, } => { create::run( - &repository, - &profile, - &workdir, message.clone(), draft, quiet, options, + &profile, + &repository, + &workdir, )?; } Operation::List { filter: Filter(f) } => { - list::run(&repository, &profile, f)?; + list::run(f, &repository, &profile)?; } Operation::Show { patch_id, diff } => { let patch_id = patch_id.resolve(&repository.backend)?; - show::run(&profile, &repository, &workdir, &patch_id, diff)?; + show::run(&patch_id, diff, &profile, &repository, &workdir)?; } Operation::Update { ref patch_id, @@ -390,34 +390,34 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { .map(|id| id.resolve(&repository.backend)) .transpose()?; update::run( - &repository, - &profile, - &workdir, patch_id, message.clone(), quiet, &options, + &profile, + &repository, + &workdir, )?; } Operation::Archive { ref patch_id } => { let patch_id = patch_id.resolve::(&repository.backend)?; - archive::run(&repository, &profile, &patch_id)?; + archive::run(&patch_id, &profile, &repository)?; } Operation::Ready { ref patch_id, undo } => { let patch_id = patch_id.resolve::(&repository.backend)?; - ready::run(&repository, &profile, &patch_id, undo)?; + ready::run(&patch_id, undo, &profile, &repository)?; } Operation::Delete { patch_id } => { let patch_id = patch_id.resolve(&repository.backend)?; - delete::run(&repository, &profile, &patch_id)?; + delete::run(&patch_id, &profile, &repository)?; } Operation::Checkout { patch_id } => { let patch_id = patch_id.resolve(&repository.backend)?; - checkout::run(&repository, &workdir, &patch_id)?; + checkout::run(&patch_id, &repository, &workdir)?; } Operation::Edit { patch_id, message } => { let patch_id = patch_id.resolve(&repository.backend)?; - edit::run(&repository, &profile, &patch_id, message)?; + edit::run(&patch_id, message, &profile, &repository)?; } } Ok(()) diff --git a/radicle-cli/src/commands/patch/archive.rs b/radicle-cli/src/commands/patch/archive.rs index 470ab6a4..4d9b4ef9 100644 --- a/radicle-cli/src/commands/patch/archive.rs +++ b/radicle-cli/src/commands/patch/archive.rs @@ -4,7 +4,7 @@ use radicle::cob::patch; use radicle::prelude::*; use radicle::storage::git::Repository; -pub fn run(repository: &Repository, profile: &Profile, patch_id: &PatchId) -> anyhow::Result<()> { +pub fn run(patch_id: &PatchId, profile: &Profile, repository: &Repository) -> anyhow::Result<()> { let signer = term::signer(profile)?; let mut patches = patch::Patches::open(repository)?; let Ok(mut patch) = patches.get_mut(patch_id) else { diff --git a/radicle-cli/src/commands/patch/checkout.rs b/radicle-cli/src/commands/patch/checkout.rs index d338f29b..ed4d4d11 100644 --- a/radicle-cli/src/commands/patch/checkout.rs +++ b/radicle-cli/src/commands/patch/checkout.rs @@ -10,9 +10,9 @@ use radicle::storage::ReadRepository; use crate::terminal as term; pub fn run( + patch_id: &PatchId, stored: &Repository, working: &git::raw::Repository, - patch_id: &PatchId, ) -> anyhow::Result<()> { let patches = patch::Patches::open(stored)?; let patch = patches diff --git a/radicle-cli/src/commands/patch/create.rs b/radicle-cli/src/commands/patch/create.rs index b0ede200..ee622452 100644 --- a/radicle-cli/src/commands/patch/create.rs +++ b/radicle-cli/src/commands/patch/create.rs @@ -46,13 +46,13 @@ fn show_patch_commit_info( /// Run patch creation. pub fn run( - storage: &Repository, - profile: &Profile, - workdir: &git::raw::Repository, message: term::patch::Message, draft: bool, quiet: bool, options: Options, + profile: &Profile, + storage: &Repository, + workdir: &git::raw::Repository, ) -> anyhow::Result<()> { let mut patches = patch::Patches::open(storage)?; let head_branch = try_branch(workdir.head()?)?; diff --git a/radicle-cli/src/commands/patch/delete.rs b/radicle-cli/src/commands/patch/delete.rs index 4023a080..9e3d185d 100644 --- a/radicle-cli/src/commands/patch/delete.rs +++ b/radicle-cli/src/commands/patch/delete.rs @@ -4,7 +4,7 @@ use radicle::storage::git::Repository; use super::*; -pub fn run(repository: &Repository, profile: &Profile, patch_id: &PatchId) -> anyhow::Result<()> { +pub fn run(patch_id: &PatchId, profile: &Profile, repository: &Repository) -> anyhow::Result<()> { let signer = &term::signer(profile)?; let patches = patch::Patches::open(repository)?; patches.remove(patch_id, signer)?; diff --git a/radicle-cli/src/commands/patch/edit.rs b/radicle-cli/src/commands/patch/edit.rs index 4ff2f86e..39734a15 100644 --- a/radicle-cli/src/commands/patch/edit.rs +++ b/radicle-cli/src/commands/patch/edit.rs @@ -7,10 +7,10 @@ use radicle::storage::git::Repository; use crate::terminal as term; pub fn run( - repository: &Repository, - profile: &Profile, patch_id: &PatchId, message: term::patch::Message, + profile: &Profile, + repository: &Repository, ) -> anyhow::Result<()> { let signer = term::signer(profile)?; let mut patches = patch::Patches::open(repository)?; diff --git a/radicle-cli/src/commands/patch/list.rs b/radicle-cli/src/commands/patch/list.rs index 3004669d..4cd00818 100644 --- a/radicle-cli/src/commands/patch/list.rs +++ b/radicle-cli/src/commands/patch/list.rs @@ -12,9 +12,9 @@ use super::common; /// List patches. pub fn run( + filter: fn(&patch::State) -> bool, repository: &Repository, profile: &Profile, - filter: fn(&patch::State) -> bool, ) -> anyhow::Result<()> { let patches = Patches::open(repository)?; diff --git a/radicle-cli/src/commands/patch/ready.rs b/radicle-cli/src/commands/patch/ready.rs index 5c58b45d..a35fca3f 100644 --- a/radicle-cli/src/commands/patch/ready.rs +++ b/radicle-cli/src/commands/patch/ready.rs @@ -5,10 +5,10 @@ use radicle::prelude::*; use radicle::storage::git::Repository; pub fn run( - repository: &Repository, - profile: &Profile, patch_id: &PatchId, undo: bool, + profile: &Profile, + repository: &Repository, ) -> anyhow::Result<()> { let signer = term::signer(profile)?; let mut patches = patch::Patches::open(repository)?; diff --git a/radicle-cli/src/commands/patch/show.rs b/radicle-cli/src/commands/patch/show.rs index bfb60593..a6a5602f 100644 --- a/radicle-cli/src/commands/patch/show.rs +++ b/radicle-cli/src/commands/patch/show.rs @@ -53,12 +53,12 @@ fn patch_commits(patch: &patch::Patch, stored: &Repository) -> anyhow::Result anyhow::Result<()> { let patches = patch::Patches::open(stored)?; let Some(patch) = patches.get(patch_id)? else { diff --git a/radicle-cli/src/commands/patch/update.rs b/radicle-cli/src/commands/patch/update.rs index 881b72dc..ecf2c7d2 100644 --- a/radicle-cli/src/commands/patch/update.rs +++ b/radicle-cli/src/commands/patch/update.rs @@ -54,13 +54,13 @@ fn show_update_commit_info( /// Run patch update. pub fn run( - storage: &Repository, - profile: &Profile, - workdir: &git::raw::Repository, patch_id: Option, message: term::patch::Message, quiet: bool, options: &Options, + profile: &Profile, + storage: &Repository, + workdir: &git::raw::Repository, ) -> anyhow::Result<()> { // `HEAD`; This is what we are proposing as a patch. let head_branch = try_branch(workdir.head()?)?; diff --git a/radicle-cli/src/commands/remote.rs b/radicle-cli/src/commands/remote.rs index da2b31af..bd17ff58 100644 --- a/radicle-cli/src/commands/remote.rs +++ b/radicle-cli/src/commands/remote.rs @@ -114,8 +114,8 @@ pub fn run(options: Options, ctx: impl Context) -> anyhow::Result<()> { let profile = ctx.profile()?; match options.op { - Operation::Add { ref id, name } => self::add::run(&working, &profile, id, name, rid)?, - Operation::Rm { ref name } => self::rm::run(&working, name)?, + Operation::Add { ref id, name } => self::add::run(rid, id, name, &profile, &working)?, + Operation::Rm { ref name } => self::rm::run(name, &working)?, Operation::List => self::list::run(&working)?, }; Ok(()) diff --git a/radicle-cli/src/commands/remote/add.rs b/radicle-cli/src/commands/remote/add.rs index d7fc87f9..5764f721 100644 --- a/radicle-cli/src/commands/remote/add.rs +++ b/radicle-cli/src/commands/remote/add.rs @@ -5,11 +5,11 @@ use crate::git::add_remote; use crate::{git, terminal as term}; pub fn run( - repository: &git::Repository, - profile: &Profile, + id: Id, pubkey: &PublicKey, name: Option, - id: Id, + profile: &Profile, + repository: &git::Repository, ) -> anyhow::Result<()> { let name = match name { Some(name) => name, diff --git a/radicle-cli/src/commands/remote/rm.rs b/radicle-cli/src/commands/remote/rm.rs index fbe49383..dc2a91e1 100644 --- a/radicle-cli/src/commands/remote/rm.rs +++ b/radicle-cli/src/commands/remote/rm.rs @@ -1,7 +1,7 @@ use crate::git; use crate::terminal as term; -pub fn run(repository: &git::Repository, name: &str) -> anyhow::Result<()> { +pub fn run(name: &str, repository: &git::Repository) -> anyhow::Result<()> { if !git::is_remote(repository, name)? { anyhow::bail!("remote `{name}` not found"); } diff --git a/radicle-cli/src/commands/sync.rs b/radicle-cli/src/commands/sync.rs index 4882c4f9..409c2c65 100644 --- a/radicle-cli/src/commands/sync.rs +++ b/radicle-cli/src/commands/sync.rs @@ -136,18 +136,18 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let mut node = radicle::Node::new(profile.socket()); match options.mode { - SyncMode::Announce => announce(rid, node, options.timeout), - SyncMode::Fetch => fetch(rid, profile, &mut node, options.seed), + SyncMode::Announce => announce(rid, options.timeout, node), + SyncMode::Fetch => fetch(rid, options.seed, &mut node, profile), SyncMode::Both => { - fetch(rid, profile, &mut node, options.seed)?; - announce(rid, node, options.timeout)?; + fetch(rid, options.seed, &mut node, profile)?; + announce(rid, options.timeout, node)?; Ok(()) } } } -fn announce(rid: Id, mut node: Node, timeout: time::Duration) -> anyhow::Result<()> { +fn announce(rid: Id, timeout: time::Duration, mut node: Node) -> anyhow::Result<()> { let seeds = node.seeds(rid)?; if !seeds.has_connections() { term::info!("Not connected to any seeds."); @@ -180,9 +180,9 @@ fn announce(rid: Id, mut node: Node, timeout: time::Duration) -> anyhow::Result< pub fn fetch( rid: Id, - profile: Profile, - node: &mut Node, seed: Option, + node: &mut Node, + profile: Profile, ) -> anyhow::Result<()> { if !profile.tracking()?.is_repo_tracked(&rid)? { anyhow::bail!("repository {rid} is not tracked"); diff --git a/radicle-cli/src/commands/track.rs b/radicle-cli/src/commands/track.rs index 6f28e634..38e93133 100644 --- a/radicle-cli/src/commands/track.rs +++ b/radicle-cli/src/commands/track.rs @@ -130,7 +130,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { track_repo(rid, scope, &mut node)?; if options.fetch { - sync::fetch(rid, profile, &mut node, None)?; + sync::fetch(rid, None, &mut node, profile)?; } } }