Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Reorder method arguments
Slack Coder committed 2 years ago
commit 3af53626f06e13fac7c7abd640ee63a7d90f8dc0
parent f2d4b9acc29b5149ffbafe6e254827ebdf3006dc
22 files changed +63 -63
modified 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) => {
modified 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<G: Signer>(
    id: Id,
+
    announce: bool,
+
    node: &mut Node,
    signer: &G,
    storage: &Storage,
-
    node: &mut Node,
-
    announce: bool,
) -> Result<(raw::Repository, Doc<Verified>, Project), CloneError> {
    let me = *signer.public_key();

modified 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(())
modified radicle-cli/src/commands/delegate/add.rs
@@ -9,7 +9,7 @@ use radicle_crypto::PublicKey;

use crate::terminal as term;

-
pub fn run<S>(profile: &Profile, storage: &S, id: Id, key: PublicKey) -> anyhow::Result<()>
+
pub fn run<S>(id: Id, key: PublicKey, profile: &Profile, storage: &S) -> anyhow::Result<()>
where
    S: WriteStorage,
{
modified 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<S>(profile: &Profile, storage: &S, id: Id) -> anyhow::Result<()>
+
pub fn run<S>(id: Id, profile: &Profile, storage: &S) -> anyhow::Result<()>
where
    S: ReadStorage,
{
modified radicle-cli/src/commands/delegate/remove.rs
@@ -9,7 +9,7 @@ use radicle_crypto::PublicKey;

use crate::terminal as term;

-
pub fn run<S>(profile: &Profile, storage: &S, id: Id, key: &PublicKey) -> anyhow::Result<()>
+
pub fn run<S>(id: Id, key: &PublicKey, profile: &Profile, storage: &S) -> anyhow::Result<()>
where
    S: WriteStorage,
{
modified 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<Assigned>,
+
    profile: &profile::Profile,
) -> anyhow::Result<()> {
    let me = *profile.id();

@@ -484,12 +484,12 @@ fn prompt_issue(
}

fn open<G: Signer>(
-
    issues: &mut Issues,
-
    signer: &G,
-
    options: &Options,
    title: Option<String>,
    description: Option<String>,
    tags: Vec<Tag>,
+
    options: &Options,
+
    issues: &mut Issues,
+
    signer: &G,
) -> anyhow::Result<()> {
    let Some((meta, description)) = prompt_issue(
        &title.unwrap_or_default(),
modified 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::<PatchId>(&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::<PatchId>(&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(())
modified 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 {
modified 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
modified 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()?)?;
modified 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)?;
modified 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)?;
modified 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)?;

modified 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)?;
modified radicle-cli/src/commands/patch/show.rs
@@ -53,12 +53,12 @@ fn patch_commits(patch: &patch::Patch, stored: &Repository) -> anyhow::Result<Ve
}

pub fn run(
+
    patch_id: &PatchId,
+
    diff: bool,
    profile: &Profile,
    stored: &Repository,
    // TODO: Should be optional.
    workdir: &git::raw::Repository,
-
    patch_id: &PatchId,
-
    diff: bool,
) -> anyhow::Result<()> {
    let patches = patch::Patches::open(stored)?;
    let Some(patch) = patches.get(patch_id)? else {
modified 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<patch::PatchId>,
    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()?)?;
modified 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(())
modified 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<String>,
-
    id: Id,
+
    profile: &Profile,
+
    repository: &git::Repository,
) -> anyhow::Result<()> {
    let name = match name {
        Some(name) => name,
modified 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");
    }
modified 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<NodeId>,
+
    node: &mut Node,
+
    profile: Profile,
) -> anyhow::Result<()> {
    if !profile.tracking()?.is_repo_tracked(&rid)? {
        anyhow::bail!("repository {rid} is not tracked");
modified 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)?;
            }
        }
    }