Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Update `rad ls` to look like other commands
cloudhead committed 2 years ago
commit a46057da1f166eee90411ee27580efd4691e9492
parent e59e196da8b8fe5df1fdcf3187e30ccf2990db3c
4 files changed +32 -15
modified radicle-cli/examples/rad-init-private.md
@@ -46,5 +46,9 @@ $ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch
✓ Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from z6MknSL…StBU8Vi..
✓ Fetched repository from 1 seed(s)
$ rad ls --private
-
heartwood rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu f2de534 radicle heartwood protocol & stack
+
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ Name        RID                                 Head      Description                        │
+
├──────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ heartwood   rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu   f2de534   radicle heartwood protocol & stack │
+
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
```
modified radicle-cli/examples/rad-init.md
@@ -24,5 +24,9 @@ Projects can be listed with the `ls` command:

```
$ rad ls
-
heartwood rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji f2de534 Radicle Heartwood Protocol & Stack
+
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ Name        RID                                 Head      Description                        │
+
├──────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ heartwood   rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji   f2de534   Radicle Heartwood Protocol & Stack │
+
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
```
modified radicle-cli/examples/rad-rm.md
@@ -3,7 +3,11 @@ First let's look at what we have locally:

```
$ rad ls
-
heartwood rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji f2de534 Radicle Heartwood Protocol & Stack
+
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ Name        RID                                 Head      Description                        │
+
├──────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ heartwood   rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji   f2de534   Radicle Heartwood Protocol & Stack │
+
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
```

Now let's delete the `heartwood` project:
modified radicle-cli/src/commands/ls.rs
@@ -26,6 +26,7 @@ Options
};

pub struct Options {
+
    #[allow(dead_code)]
    verbose: bool,
    public: bool,
    private: bool,
@@ -70,26 +71,30 @@ impl Args for Options {
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
    let profile = ctx.profile()?;
    let storage = &profile.storage;
-
    let mut table = term::Table::default();
+
    let mut table = term::Table::new(term::TableOptions::bordered());
+
    let repos = storage.repositories()?;

-
    for RepositoryInfo { rid, head, doc } in storage.repositories()? {
+
    if repos.is_empty() {
+
        return Ok(());
+
    }
+
    table.push([
+
        "Name".into(),
+
        "RID".into(),
+
        "Head".into(),
+
        "Description".into(),
+
    ]);
+
    table.divider();
+

+
    for RepositoryInfo { rid, head, doc } in repos {
        if doc.visibility.is_public() && options.private && !options.public {
            continue;
        }
        if !doc.visibility.is_public() && !options.private && options.public {
            continue;
        }
-

-
        let proj = match doc.verified()?.project() {
-
            Ok(proj) => proj,
-
            Err(err) => {
-
                if options.verbose {
-
                    term::warning(&format!("failed to get local project '{rid}': {err}"));
-
                }
-
                continue;
-
            }
-
        };
+
        let proj = doc.verified()?.project()?;
        let head = term::format::oid(head).into();
+

        table.push([
            term::format::bold(proj.name().to_owned()),
            term::format::tertiary(rid.urn()),