Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add `--head COUNT` for `rad sync status`
✗ CI failure Matthias Beyer committed 1 month ago
commit b042504faba306e08c01824fe9b00846408afe89
parent 7bac17146c40b32b2ce0e27b96a555a44f3ef2ba
1 failed (1 total) View logs
3 files changed +11 -3
modified CHANGELOG.md
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
  configuration file. The default values used are `WAL` and `NORMAL`, which
  generates less I/O operations. On power loss, transactions might be rolled
  back, but SQLite still guarantees consistency in this mode.
+
- `rad sync status` learned `--head COUNT` to truncate the printed table after
+
  `COUNT` entries.

## Fixed Bugs

modified crates/radicle-cli/src/commands/sync.rs
@@ -40,7 +40,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    let debug = args.verbose;

    match args.command {
-
        Some(Command::Status { rid, sort_by }) => {
+
        Some(Command::Status { rid, sort_by, head }) => {
            let rid = match rid {
                Some(rid) => rid,
                None => {
@@ -49,7 +49,7 @@ pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
                    rid
                }
            };
-
            sync_status(rid, &mut node, &profile, &sort_by, verbose)?;
+
            sync_status(rid, &mut node, &profile, &sort_by, verbose, head)?;
        }
        None => match SyncMode::from(args.sync) {
            SyncMode::Repo {
@@ -93,6 +93,7 @@ fn sync_status(
    profile: &Profile,
    sort_by: &SortBy,
    verbose: bool,
+
    head: Option<usize>,
) -> anyhow::Result<()> {
    const SYMBOL_STATE: &str = "?";
    const SYMBOL_STATE_UNKNOWN: &str = "•";
@@ -113,7 +114,8 @@ fn sync_status(

    sort_seeds_by(local_nid, &mut seeds, &aliases, sort_by);

-
    let seeds = seeds.into_iter().flat_map(|seed| {
+
    let head = head.unwrap_or(usize::MAX);
+
    let seeds = seeds.into_iter().take(head).flat_map(|seed| {
        let (status, head, time) = match seed.sync {
            Some(SyncStatus::Synced {
                at: SyncedAt { oid, timestamp },
modified crates/radicle-cli/src/commands/sync/args.rs
@@ -167,6 +167,10 @@ pub(super) enum Command {
        /// Sort the table by column
        #[arg(long, value_name = "FIELD", value_enum, default_value_t)]
        sort_by: SortBy,
+

+
        /// Only show the first COUNT table entries
+
        #[arg(long, value_name = "COUNT")]
+
        head: Option<usize>,
    },
}