Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: introduce module
◌ CI pending Fintan Halpenny committed 7 months ago
commit 9ea000f90fc92fac9b4fad2fad8ac5d5c7937e39
parent 7ebf864e8817a6e1a80a5f44bcc6f4bec0765ab9
1 pending (1 total) View logs
2 files changed +33 -29
modified crates/radicle-cli/src/commands/ls.rs
@@ -1,4 +1,7 @@
-
use clap::Parser;
+
mod args;
+

+
pub use args::Args;
+
pub(crate) use args::ABOUT;

use radicle::storage::{ReadStorage, RepositoryInfo};

@@ -6,32 +9,6 @@ use crate::terminal as term;

use term::Element;

-
pub(crate) const ABOUT: &str = "List repositories";
-
const LONG_ABOUT: &str = r#"
-
By default, this command shows you all repositories that you have forked or initialized.
-
If you wish to see all seeded repositories, use the `--seeded` option.
-
"#;
-

-
#[derive(Debug, Parser)]
-
#[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)]
-
pub struct Args {
-
    /// Show only private repositories
-
    #[arg(long)]
-
    private: bool,
-
    /// Show only public repositories
-
    #[arg(long)]
-
    public: bool,
-
    /// Show all seeded repositories
-
    #[arg(short, long)]
-
    seeded: bool,
-
    /// Show all repositories in storage
-
    #[arg(short, long)]
-
    all: bool,
-
    /// Verbose output
-
    #[arg(short, long)]
-
    verbose: bool,
-
}
-

pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    let profile = ctx.profile()?;
    let storage = &profile.storage;
@@ -52,10 +29,10 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
        ..
    } in repos
    {
-
        if doc.is_public() && args.private && !args.public {
+
        if doc.is_public() && args.private {
            continue;
        }
-
        if !doc.is_public() && !args.private && args.public {
+
        if !doc.is_public() && args.public {
            continue;
        }
        if refs.is_none() && !args.all && !args.seeded {
added crates/radicle-cli/src/commands/ls/args.rs
@@ -0,0 +1,27 @@
+
use clap::Parser;
+

+
pub(crate) const ABOUT: &str = "List repositories";
+
const LONG_ABOUT: &str = r#"
+
By default, this command shows you all repositories that you have forked or initialized.
+
If you wish to see all seeded repositories, use the `--seeded` option.
+
"#;
+

+
#[derive(Debug, Parser)]
+
#[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)]
+
pub struct Args {
+
    /// Show only private repositories
+
    #[arg(long, conflicts_with = "public")]
+
    pub(super) private: bool,
+
    /// Show only public repositories
+
    #[arg(long)]
+
    pub(super) public: bool,
+
    /// Show all seeded repositories
+
    #[arg(short, long)]
+
    pub(super) seeded: bool,
+
    /// Show all repositories in storage
+
    #[arg(short, long)]
+
    pub(super) all: bool,
+
    /// Verbose output
+
    #[arg(short, long)]
+
    pub(super) verbose: bool,
+
}