Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
term: Rename print to println
Fintan Halpenny committed 1 day ago
commit 2262b8d9bd7880b536c3d1ce8b462e5dc3480303
parent e7d519c
23 files changed +78 -78
modified crates/radicle-cli/src/commands/auth.rs
@@ -158,10 +158,10 @@ pub fn authenticate(args: Args, profile: &Profile) -> anyhow::Result<()> {
        return Ok(());
    }

-
    term::print(term::format::dim(
+
    term::println(term::format::dim(
        "Nothing to do, ssh-agent is not running.",
    ));
-
    term::print(term::format::dim(
+
    term::println(term::format::dim(
        "You will be prompted for a passphrase when necessary.",
    ));

modified crates/radicle-cli/src/commands/cob.rs
@@ -80,7 +80,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                    oid
                }
            };
-
            term::print(oid);
+
            term::println(oid);
        }
        Migrate => {
            let mut db = profile.cobs_db_mut()?;
@@ -100,7 +100,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                FilteredTypeName::from(type_name).as_ref(),
            )?;
            for cob in cobs {
-
                term::print(cob.id);
+
                term::println(cob.id);
            }
        }
        Log {
@@ -215,7 +215,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                }
            };

-
            term::print(oid);
+
            term::println(oid);
        }
    }
    Ok(())
@@ -303,18 +303,18 @@ where
        std::time::UNIX_EPOCH + std::time::Duration::from_secs(op.timestamp.as_secs()),
    )
    .to_rfc2822();
-
    term::print(term::format::yellow(format!("commit   {}", op.id)));
+
    term::println(term::format::yellow(format!("commit   {}", op.id)));
    if let Some(oid) = op.identity {
-
        term::print(term::format::tertiary(format!("resource {oid}")));
+
        term::println(term::format::tertiary(format!("resource {oid}")));
    }
    for parent in op.parents {
-
        term::print(format!("parent   {parent}"));
+
        term::println(format!("parent   {parent}"));
    }
    for parent in op.related {
-
        term::print(format!("rel      {parent}"));
+
        term::println(format!("rel      {parent}"));
    }
-
    term::print(format!("author   {}", op.author));
-
    term::print(format!("date     {time}"));
+
    term::println(format!("author   {}", op.author));
+
    term::println(format!("date     {time}"));
    term::blank();
    for action in op.actions {
        let val = serde_json::to_string_pretty(&action)?;
@@ -330,7 +330,7 @@ fn print_op_json<A>(op: cob::Op<A>) -> anyhow::Result<()>
where
    A: serde::Serialize,
{
-
    term::print(serde_json::to_value(&op)?);
+
    term::println(serde_json::to_value(&op)?);
    Ok(())
}

modified crates/radicle-cli/src/commands/config.rs
@@ -102,10 +102,10 @@ where
fn print_value(value: &serde_json::Value) -> anyhow::Result<()> {
    match value {
        serde_json::Value::Null => {}
-
        serde_json::Value::Bool(b) => term::print(b),
+
        serde_json::Value::Bool(b) => term::println(b),
        serde_json::Value::Array(a) => a.iter().try_for_each(print_value)?,
-
        serde_json::Value::Number(n) => term::print(n),
-
        serde_json::Value::String(s) => term::print(s),
+
        serde_json::Value::Number(n) => term::println(n),
+
        serde_json::Value::String(s) => term::println(s),
        serde_json::Value::Object(o) => {
            term::json::to_pretty(&o, Path::new("config.json"))?.print()
        }
modified crates/radicle-cli/src/commands/debug.rs
@@ -60,7 +60,7 @@ fn debug(profile: Option<&Profile>) -> anyhow::Result<()> {
        warnings: collect_warnings(profile),
    };

-
    term::print(serde_json::to_string_pretty(&debug).unwrap());
+
    term::println(serde_json::to_string_pretty(&debug).unwrap());

    Ok(())
}
modified crates/radicle-cli/src/commands/id.rs
@@ -167,7 +167,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                {
                    Some(proposal) => serde_json::from_str::<RawDoc>(&proposal)?,
                    None => {
-
                        term::print(term::format::italic(
+
                        term::println(term::format::italic(
                            "Nothing to do. The document is up to date. See `rad inspect --identity`.",
                        ));
                        return Ok(());
@@ -180,7 +180,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
            let proposal = update::verify(proposal)?;
            if proposal == current.doc {
                if !args.quiet {
-
                    term::print(term::format::italic(
+
                    term::println(term::format::italic(
                        "Nothing to do. The document is up to date. See `rad inspect --identity`.",
                    ));
                }
@@ -193,7 +193,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                repo.set_identity_head_to(revision.id)?;
            }
            if args.quiet {
-
                term::print(revision.id);
+
                term::println(revision.id);
            } else {
                term::success!(
                    "Identity revision {} created",
@@ -516,7 +516,7 @@ fn print_diff(
        let diff = modified.diff.to_unified_string()?;
        term::print_inline(diff);
    } else {
-
        term::print(term::format::italic("No changes."));
+
        term::println(term::format::italic("No changes."));
    }
    Ok(())
}
modified crates/radicle-cli/src/commands/inbox.rs
@@ -96,7 +96,7 @@ fn list(
    };

    if repos.is_empty() {
-
        term::print(term::format::italic("Your inbox is empty."));
+
        term::println(term::format::italic("Your inbox is empty."));
    } else {
        for repo in repos {
            repo.print();
@@ -397,7 +397,7 @@ fn clear(notifs: &mut notifications::StoreWriter, mode: ClearMode) -> anyhow::Re
    if cleared > 0 {
        term::success!("Cleared {cleared} item(s) from your inbox");
    } else {
-
        term::print(term::format::italic("Your inbox is empty."));
+
        term::println(term::format::italic("Your inbox is empty."));
    }
    Ok(())
}
modified crates/radicle-cli/src/commands/inspect.rs
@@ -68,7 +68,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                let refs = RefsAt::new(&repo, remote)?;
                let sigrefs = SignedRefs::load_at(refs.at, remote, &repo);

-
                term::print(format_args!(
+
                term::println(format_args!(
                    "{:<48} {} {}",
                    term::format::tertiary(remote.to_human()),
                    term::format::secondary(refs.at),
@@ -111,7 +111,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
            let seed = policies.seed_policy(&rid)?;
            match seed.policy {
                SeedingPolicy::Allow { scope } => {
-
                    term::print(format_args!(
+
                    term::println(format_args!(
                        "Repository {} is {} with scope {}",
                        term::format::tertiary(&rid),
                        term::format::positive("being seeded"),
@@ -119,7 +119,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                    ));
                }
                SeedingPolicy::Block => {
-
                    term::print(format_args!(
+
                    term::println(format_args!(
                        "Repository {} is {}",
                        term::format::tertiary(&rid),
                        term::format::negative("not being seeded"),
@@ -132,19 +132,19 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
            let aliases = profile.aliases();
            for did in doc.delegates().iter() {
                if let Some(alias) = aliases.alias(did) {
-
                    term::print(format_args!(
+
                    term::println(format_args!(
                        "{} {}",
                        term::format::tertiary(&did),
                        term::format::parens(term::format::dim(alias))
                    ));
                } else {
-
                    term::print(term::format::tertiary(&did));
+
                    term::println(term::format::tertiary(&did));
                }
            }
        }
        Target::Visibility => {
            let (_, doc) = repo(rid, storage)?;
-
            term::print(term::format::visibility(doc.visibility()));
+
            term::println(term::format::visibility(doc.visibility()));
        }
        Target::History => {
            let (repo, _) = repo(rid, storage)?;
@@ -177,16 +177,16 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                .with_timezone(&timezone)
                .to_rfc2822();

-
                term::print(format_args!(
+
                term::println(format_args!(
                    "{} {}",
                    term::format::yellow("commit"),
                    term::format::yellow(oid),
                ));
                if let Ok(parent) = tip.parent_id(0) {
-
                    term::print(format_args!("parent {parent}"));
+
                    term::println(format_args!("parent {parent}"));
                }
-
                term::print(format_args!("blob   {}", revision.blob));
-
                term::print(format_args!("date   {time}"));
+
                term::println(format_args!("blob   {}", revision.blob));
+
                term::println(format_args!("date   {time}"));
                term::blank();

                if let Some(msg) = tip.message() {
@@ -200,7 +200,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                    term::blank();
                }
                for line in json::to_pretty(&doc, Path::new("radicle.json"))? {
-
                    term::print(format_args!(" {line}"));
+
                    term::println(format_args!(" {line}"));
                }

                term::blank();
modified crates/radicle-cli/src/commands/issue.rs
@@ -239,7 +239,7 @@ where
    C: issue::cache::Issues,
{
    if cache.is_empty()? {
-
        term::print(term::format::italic("Nothing to show."));
+
        term::println(term::format::italic("Nothing to show."));
        return Ok(());
    }

modified crates/radicle-cli/src/commands/issue/comment.rs
@@ -39,7 +39,7 @@ where

    let comment_id = issue.comment(body, reply_to.unwrap_or(*root_comment_id), vec![])?;
    if quiet {
-
        term::print(comment_id);
+
        term::println(comment_id);
    } else {
        let comment = issue.thread().comment(&comment_id).unwrap();
        term::comment::widget(&comment_id, comment, profile).print();
@@ -82,7 +82,7 @@ where
    )?;
    issue.edit_comment(comment_id, body, vec![])?;
    if quiet {
-
        term::print(comment_id);
+
        term::println(comment_id);
    } else {
        let comment = issue.thread().comment(&comment_id).unwrap();
        term::comment::widget(&comment_id, comment, profile).print();
modified crates/radicle-cli/src/commands/ls.rs
@@ -69,7 +69,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    rows.sort();

    if rows.is_empty() {
-
        term::print(term::format::italic("Nothing to show."));
+
        term::println(term::format::italic("Nothing to show."));
    } else {
        table.header([
            "Name".into(),
modified crates/radicle-cli/src/commands/node.rs
@@ -47,7 +47,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
            if addresses {
                let cfg = node.config()?;
                for addr in cfg.external_addresses {
-
                    term::print(ConnectAddress::from((*profile.id(), addr)).to_string());
+
                    term::println(ConnectAddress::from((*profile.id(), addr)).to_string());
                }
            } else {
                control::config(&node)?;
@@ -88,14 +88,14 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
        Command::Inventory { nid } => {
            let nid = nid.as_ref().unwrap_or(profile.id());
            for rid in profile.routing()?.get_inventory(nid)? {
-
                term::print(term::format::tertiary(rid));
+
                term::println(term::format::tertiary(rid));
            }
        }
        Command::Status {
            only: Some(Only::Nid),
        } => {
            if node.is_running() {
-
                term::print(term::format::node_id_human(&node.nid()?));
+
                term::println(term::format::node_id_human(&node.nid()?));
            } else {
                process::exit(2);
            }
modified crates/radicle-cli/src/commands/node/commands.rs
@@ -13,7 +13,7 @@ pub fn db(profile: &Profile, op: DbOperation) -> anyhow::Result<()> {
            if changed > 0 {
                term::success!("{changed} row(s) affected.");
            } else {
-
                term::print(term::format::italic("No rows affected."));
+
                term::println(term::format::italic("No rows affected."));
            }
        }
    }
modified crates/radicle-cli/src/commands/node/control.rs
@@ -83,7 +83,7 @@ pub fn start(
                    spinner.message(format!("Node started {pid}"));
                    spinner.finish();

-
                    term::print(term::format::dim(
+
                    term::println(term::format::dim(
                        "To stay in sync with the network, leave the node running in the background.",
                    ));
                    term::info!(
@@ -414,7 +414,7 @@ pub fn config(node: &Node) -> anyhow::Result<()> {
    let cfg = node.config()?;
    let cfg = serde_json::to_string_pretty(&cfg)?;

-
    term::print(cfg);
+
    term::println(cfg);

    Ok(())
}
modified crates/radicle-cli/src/commands/node/events.rs
@@ -13,7 +13,7 @@ where
        let event = event?;
        let obj = serde_json::to_string(&event)?;

-
        term::print(&obj);
+
        term::println(&obj);

        // Only output up to `count` events.
        if i + 1 >= count {
modified crates/radicle-cli/src/commands/node/routing.rs
@@ -44,6 +44,6 @@ fn print_table(entries: impl IntoIterator<Item = (RepoId, NodeId)>) {

fn print_json(entries: impl IntoIterator<Item = (RepoId, NodeId)>) {
    for (rid, nid) in entries {
-
        term::print(serde_json::json!({ "rid": rid, "nid": nid }));
+
        term::println(serde_json::json!({ "rid": rid, "nid": nid }));
    }
}
modified crates/radicle-cli/src/commands/patch/comment.rs
@@ -46,7 +46,7 @@ pub fn run(
        .ok_or(anyhow!("error retrieving comment `{comment_id}`"))?;

    if quiet {
-
        term::print(comment_id);
+
        term::println(comment_id);
    } else {
        term::comment::widget(&comment_id, comment, profile).print();
    }
modified crates/radicle-cli/src/commands/patch/list.rs
@@ -46,7 +46,7 @@ pub fn run(
    }

    if all.is_empty() {
-
        term::print(term::format::italic("Nothing to show."));
+
        term::println(term::format::italic("Nothing to show."));
        return Ok(());
    }

modified crates/radicle-cli/src/commands/patch/update.rs
@@ -48,7 +48,7 @@ pub fn run(
    let message = term::patch::get_update_message(message, workdir, revision, &head_oid.into())?;
    let revision = patch.update(message, base_oid, head_oid)?;

-
    term::print(revision);
+
    term::println(revision);

    Ok(())
}
modified crates/radicle-cli/src/commands/path.rs
@@ -9,7 +9,7 @@ pub use args::Args;
pub fn run(_args: Args, _ctx: impl term::Context) -> anyhow::Result<()> {
    let home = profile::home()?;

-
    term::print(home.path().display());
+
    term::println(home.path().display());

    Ok(())
}
modified crates/radicle-cli/src/commands/seed.rs
@@ -112,7 +112,7 @@ pub fn seeding(profile: &Profile) -> anyhow::Result<()> {
    }

    if t.is_empty() {
-
        term::print(term::format::dim("No seeding policies to show."));
+
        term::println(term::format::dim("No seeding policies to show."));
    } else {
        t.print();
    }
modified crates/radicle-cli/src/commands/self.rs
@@ -14,20 +14,20 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    let profile = ctx.profile()?;

    if args.did {
-
        term::print(profile.did());
+
        term::println(profile.did());
    } else if args.alias {
-
        term::print(profile.config.alias());
+
        term::println(profile.config.alias());
    } else if args.home {
-
        term::print(profile.home().path().display());
+
        term::println(profile.home().path().display());
    } else if args.ssh_key {
-
        term::print(ssh::fmt::key(profile.id()));
+
        term::println(ssh::fmt::key(profile.id()));
    } else if args.config {
-
        term::print(profile.home.config().display());
+
        term::println(profile.home.config().display());
    } else if args.ssh_fingerprint {
-
        term::print(ssh::fmt::fingerprint(profile.id()));
+
        term::println(ssh::fmt::fingerprint(profile.id()));
    } else if args.nid {
        crate::warning::deprecated("rad self --nid", "rad node status --only nid");
-
        term::print(
+
        term::println(
            Node::new(profile.socket_from_env())
                .nid()
                .ok()
modified crates/radicle-cli/src/commands/sync.rs
@@ -198,7 +198,7 @@ fn announce_refs(
    };
    if let Err(e) = repo.remote(&profile.public_key) {
        if e.is_not_found() {
-
            term::print(term::format::italic(
+
            term::println(term::format::italic(
                "Nothing to announce, you don't have a fork of this repository.",
            ));
            return Ok(());
modified crates/radicle-term/src/io.rs
@@ -74,7 +74,7 @@ macro_rules! info {
        writeln!($writer, $($arg)*).ok();
    });
    ($($arg:tt)*) => ({
-
        $crate::io::print(format_args!($($arg)*));
+
        $crate::io::println(format_args!($($arg)*));
    })
}

@@ -118,7 +118,7 @@ pub fn success_args<W: io::Write>(w: &mut W, args: fmt::Arguments) {
}

pub fn tip_args(args: fmt::Arguments) {
-
    print(format_args!(
+
    println(format_args!(
        "{} {}",
        format::yellow("*"),
        style(format!("{args}")).italic()
@@ -148,23 +148,23 @@ pub fn viewport() -> Option<Size> {
}

pub fn headline(headline: impl fmt::Display) {
-
    print("");
-
    print(style(headline).bold());
-
    print("");
+
    println("");
+
    println(style(headline).bold());
+
    println("");
}

pub fn header(header: &str) {
-
    print("");
-
    print(style(format::yellow(header)).bold().underline());
-
    print("");
+
    println("");
+
    println(style(format::yellow(header)).bold().underline());
+
    println("");
}

pub fn blob(text: impl fmt::Display) {
-
    print(style(text.to_string().trim()).dim());
+
    println(style(text.to_string().trim()).dim());
}

pub fn blank() {
-
    print("");
+
    println("");
}

/// Print a line to stdout, silently ignoring broken pipe errors.
@@ -177,7 +177,7 @@ pub fn blank() {
/// # Panics
///
/// If writing to standard output fails with an error not of kind [`io::ErrorKind::BrokenPipe`].
-
pub fn print(msg: impl fmt::Display) {
+
pub fn println(msg: impl fmt::Display) {
    use io::Write;

    let mut stdout = io::stdout().lock();
@@ -190,7 +190,7 @@ pub fn print(msg: impl fmt::Display) {
/// Use this function instead of [`print!`] when you want to print to standard
/// output, but silently ignore broken pipe errors.
///
-
/// See also [`self::print`].
+
/// See also [`self::println`].
///
/// # Panics
///
@@ -228,7 +228,7 @@ pub fn prefixed(prefix: &str, text: &str) -> String {
}

pub fn help(name: &str, version: &str, description: &str, usage: &str) {
-
    print(format_args!("rad-{name} {version}\n{description}\n{usage}"));
+
    println(format_args!("rad-{name} {version}\n{description}\n{usage}"));
}

pub fn manual(name: &str) -> io::Result<process::ExitStatus> {
@@ -241,7 +241,7 @@ pub fn manual(name: &str) -> io::Result<process::ExitStatus> {
}

pub fn usage(name: &str, usage: &str) {
-
    print(format_args!(
+
    println(format_args!(
        "{} {}\n{}",
        PREFIX_ERROR,
        Paint::red(format!("Error: rad-{name}: invalid usage")),
@@ -250,19 +250,19 @@ pub fn usage(name: &str, usage: &str) {
}

pub fn println_prefixed(prefix: impl fmt::Display, msg: impl fmt::Display) {
-
    print(format_args!("{prefix} {msg}"));
+
    println(format_args!("{prefix} {msg}"));
}

pub fn indented(msg: impl fmt::Display) {
-
    print(format_args!("{TAB}{msg}"));
+
    println(format_args!("{TAB}{msg}"));
}

pub fn subcommand(msg: impl fmt::Display) {
-
    print(style(format!("Running `{msg}`...")).dim());
+
    println(style(format!("Running `{msg}`...")).dim());
}

pub fn warning(warning: impl fmt::Display) {
-
    print(format_args!(
+
    println(format_args!(
        "{} {} {warning}",
        PREFIX_WARNING,
        Paint::yellow("Warning:").bold(),
@@ -270,14 +270,14 @@ pub fn warning(warning: impl fmt::Display) {
}

pub fn error(error: impl fmt::Display) {
-
    print(format_args!(
+
    println(format_args!(
        "{PREFIX_ERROR} {} {error}",
        Paint::red("Error:")
    ));
}

pub fn hint(hint: impl fmt::Display) {
-
    print(format::hint(format!("{SYMBOL_ERROR} Hint: {hint}")));
+
    println(format::hint(format!("{SYMBOL_ERROR} Hint: {hint}")));
}

pub fn ask<D: fmt::Display>(prompt: D, default: bool) -> bool {