Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Update `inspect` command
Alexis Sellier committed 3 years ago
commit a6066e3ac3ff2d84a6987d9efa469f32c40d64ac
parent 1eb2a5ab9d0f5747f8e4e579691659a8bd8b789d
4 files changed +32 -21
modified radicle-cli/examples/rad-init.md
@@ -16,10 +16,10 @@ ok Project heartwood created


Your project id is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. You can show it any time by running:
-
   rad .
+
    rad .

To publish your project to the network, run:
-
   rad push
+
    rad push

```

modified radicle-cli/src/commands/init.rs
@@ -234,11 +234,11 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
                "Your project id is {}. You can show it any time by running:",
                term::format::highlight(id)
            );
-
            term::indented(&term::format::secondary("rad ."));
+
            term::indented(term::format::secondary("rad ."));

            term::blank();
            term::info!("To publish your project to the network, run:");
-
            term::indented(&term::format::secondary("rad push"));
+
            term::indented(term::format::secondary("rad push"));
            term::blank();
        }
        Err(err) => {
modified radicle-cli/src/commands/inspect.rs
@@ -149,10 +149,9 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
    } else if options.history {
        let repo = storage.repository(id)?;
        let head = Doc::<Untrusted>::head(signer.public_key(), &repo)?;
-
        let history = repo.revwalk(head)?.collect::<Vec<_>>();
-
        let revision = history.len();
+
        let history = repo.revwalk(head)?.collect::<Vec<_>>().into_iter();

-
        for (counter, oid) in history.into_iter().rev().enumerate() {
+
        for oid in history {
            let oid = oid?.into();
            let tip = repo.commit(oid)?;
            let blob = Doc::<Unverified>::blob_at(oid, &repo)?;
@@ -170,18 +169,30 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
            .with_timezone(&timezone)
            .to_rfc2822();

-
            print!(
-
                "{}",
-
                term::TextBox::new(format!(
-
                    "commit {}\nblob   {}\ndate   {}\n\n{}",
-
                    term::format::yellow(oid),
-
                    term::format::dim(blob.id()),
-
                    term::format::dim(time),
-
                    colorizer().colorize_json_str(&serde_json::to_string_pretty(&content)?)?,
-
                ))
-
                .first(counter == 0)
-
                .last(counter + 1 == revision)
+
            println!(
+
                "{} {}",
+
                term::format::yellow("commit"),
+
                term::format::yellow(oid),
            );
+
            if let Ok(parent) = tip.parent_id(0) {
+
                println!("parent {}", parent);
+
            }
+
            println!("blob   {}", blob.id());
+
            println!("date   {}", time);
+
            println!();
+

+
            if let Some(msg) = tip.message() {
+
                for line in msg.lines() {
+
                    term::indented(term::format::dim(line));
+
                }
+
                term::blank();
+
            }
+

+
            let json = colorizer().colorize_json_str(&serde_json::to_string_pretty(&content)?)?;
+
            for line in json.lines() {
+
                println!(" {line}");
+
            }
+
            println!();
        }
    } else if options.id_only {
        term::info!("{}", term::format::highlight(id.to_human()));
@@ -196,7 +207,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
fn colorizer() -> Colorizer {
    Colorizer::new()
        .null(Color::Cyan)
-
        .boolean(Color::Yellow)
+
        .boolean(Color::Cyan)
        .number(Color::Magenta)
        .string(Color::Green)
        .key(Color::Blue)
modified radicle-cli/src/terminal/io.rs
@@ -17,7 +17,7 @@ use super::format;
use super::spinner::spinner;
use super::Error;

-
pub const TAB: &str = "   ";
+
pub const TAB: &str = "    ";

#[macro_export]
macro_rules! info {
@@ -103,7 +103,7 @@ pub fn eprintln(prefix: impl fmt::Display, msg: impl fmt::Display) {
    eprintln!("{} {}", prefix, msg);
}

-
pub fn indented(msg: &str) {
+
pub fn indented(msg: impl fmt::Display) {
    println!("{}{}", TAB, msg);
}