Skip to content

Commit

Permalink
Added --depth and --short to sdf status for more concise summaries.
Browse files Browse the repository at this point in the history
 - New friendlier, concise status options. First, --depth merges statuses
   by a certain level of directory depth. Second, --short is --depth 2
   plus an even more concise message per directory.

 - Fixed issue where file names were not being sorted lexicographically
   when displayed with sdf status.

 - Option --no-color added.

 - Time sorting (-t/--time) and reversed order (-r/--remote) added
   to sdf status.

 - Some refactor of code into src/lib/status.rs.

 - Fixed bug with total counts.
  • Loading branch information
vsbuffalo committed Nov 2, 2024
1 parent a526ac3 commit 5e5162e
Show file tree
Hide file tree
Showing 8 changed files with 527 additions and 171 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
given-names: "Vince"
orcid: "https://orcid.org/0000-0003-4510-1609"
title: "SciDataFlow: A Tool for Improving the Flow of Data through Science"
version: 0.8.11
version: 0.8.12
doi: http://dx.doi.org/10.1093/bioinformatics/btad754
date-released: 2024-01-05
url: "https://github.com/vsbuffalo/scidataflow/"
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scidataflow"
version = "0.8.11"
version = "0.8.12"
edition = "2021"
exclude = ["logo.png", "tests/test_data/**"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod lib {
pub mod progress;
pub mod project;
pub mod remote;
pub mod status;
pub mod test_utilities;
pub mod utils;
}
Expand Down
12 changes: 8 additions & 4 deletions src/lib/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::lib::utils::{load_file, pluralize, print_status};
#[allow(unused_imports)]
use crate::{print_info, print_warn};

use super::status::StatusDisplayOptions;
use super::utils::is_directory;

const MANIFEST: &str = "data_manifest.yml";
Expand Down Expand Up @@ -309,13 +310,16 @@ impl Project {
self.save()
}

pub async fn status(&mut self, include_remotes: bool, all: bool) -> Result<()> {
pub async fn status(&mut self, display_options: &StatusDisplayOptions) -> Result<()> {
// if include_remotes (e.g. --remotes) is set, we need to merge
// in the remotes, so we authenticate first and then get them.
let path_context = &canonicalize(self.path_context())?;
let status_rows = self.data.status(path_context, include_remotes).await?;
//let remotes: Option<_> = include_remotes.then(|| &self.data.remotes);
print_status(status_rows, Some(&self.data.remotes), all);
let status_rows = self
.data
.status(path_context, display_options.remotes)
.await?;

print_status(status_rows, Some(&self.data.remotes), display_options);
Ok(())
}

Expand Down
47 changes: 47 additions & 0 deletions src/lib/status.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use clap::Parser;

/// Status display options
#[derive(Parser, Debug)]
pub struct StatusDisplayOptions {
/// Show remotes status (requires network).
#[arg(short = 'm', long)]
pub remotes: bool,

/// Show statuses of all files, including those on remote(s)
/// but not in the manifest.
#[arg(short, long)]
pub all: bool,

/// Don't print status with terminal colors.
#[arg(long)]
pub no_color: bool,

/// A more terse summary, with --depth 2.
#[arg(short, long)]
pub short: bool,

/// Depth to summarize over.
#[arg(short, long)]
depth: Option<usize>,

/// Sort by time, showing the most recently modified files at
/// the top.
#[arg(short, long)]
pub time: bool,

/// Reverse file order (if --time set, will show the files
/// with the oldest modification time at the top; otherwise
/// it will list files in reverse lexicographic order).
#[arg(short, long)]
pub reverse: bool,
}

impl StatusDisplayOptions {
pub fn get_depth(&self) -> Option<usize> {
if self.short {
// --short includes
return Some(2);
}
self.depth
}
}
Loading

0 comments on commit 5e5162e

Please sign in to comment.