From 0a3da17fadadda149035fcf1e715dc575f340ce8 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Wed, 31 Jan 2024 17:24:59 +0100 Subject: [PATCH] cli: Add `--seeds` option to `ls` Small addition that is useful. --- radicle-cli/examples/rad-clone.md | 2 +- radicle-cli/examples/rad-unseed.md | 2 ++ radicle-cli/src/commands/ls.rs | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/radicle-cli/examples/rad-clone.md b/radicle-cli/examples/rad-clone.md index e25d062e..88adebc6 100644 --- a/radicle-cli/examples/rad-clone.md +++ b/radicle-cli/examples/rad-clone.md @@ -65,7 +65,7 @@ Date: Mon Jan 1 14:39:16 2018 +0000 Cloned repositories show up in `rad ls`: ``` -$ rad ls --all +$ rad ls --seeds ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ Name RID Visibility Head Description │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤ diff --git a/radicle-cli/examples/rad-unseed.md b/radicle-cli/examples/rad-unseed.md index 80559ff4..4bc06875 100644 --- a/radicle-cli/examples/rad-unseed.md +++ b/radicle-cli/examples/rad-unseed.md @@ -21,6 +21,8 @@ Now, if we run `rad ls`, we see it's gone: ``` $ rad ls Nothing to show. +$ rad ls --seeds +Nothing to show. ``` However, with the `--all` flag, we can see it still, but as local-only: diff --git a/radicle-cli/src/commands/ls.rs b/radicle-cli/src/commands/ls.rs index ce8797ab..7f08dac1 100644 --- a/radicle-cli/src/commands/ls.rs +++ b/radicle-cli/src/commands/ls.rs @@ -23,7 +23,8 @@ Options --private Show only private repositories --public Show only public repositories - --all Show all repositories in storage + --seeds, -s Show all seeded repositories + --all, -a Show all repositories in storage --verbose, -v Verbose output --help Print help "#, @@ -35,6 +36,7 @@ pub struct Options { public: bool, private: bool, all: bool, + seeds: bool, } impl Args for Options { @@ -46,15 +48,19 @@ impl Args for Options { let mut private = false; let mut public = false; let mut all = false; + let mut seeds = false; while let Some(arg) = parser.next()? { match arg { Long("help") | Short('h') => { return Err(Error::Help.into()); } - Long("all") => { + Long("all") | Short('a') => { all = true; } + Long("seeds") | Short('s') => { + seeds = true; + } Long("private") => { private = true; } @@ -72,6 +78,7 @@ impl Args for Options { private, public, all, + seeds, }, vec![], )) @@ -103,7 +110,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { if !doc.visibility.is_public() && !options.private && options.public { continue; } - if refs.is_none() && !options.all { + if refs.is_none() && !options.all && !options.seeds { continue; } let seeded = policy.is_seeding(&rid)?; @@ -111,6 +118,9 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { if !seeded && !options.all { continue; } + if !seeded && options.seeds { + continue; + } let proj = doc.project()?; let head = term::format::oid(head).into();