Skip to content

Commit

Permalink
Add actions and filters as subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsan committed May 16, 2023
1 parent 0e36272 commit 60df64e
Show file tree
Hide file tree
Showing 20 changed files with 672 additions and 364 deletions.
120 changes: 120 additions & 0 deletions Cargo.lock

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

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ members = ["crates/organize-rs_core"]
default = []
research_organize = []

[[example]]
name = "parse-py-config"
path = "examples/parse_py_organize_config.rs"
test = true
bench = true
doc = true
harness = true
edition = "2021"

[workspace.dependencies]
organize-rs_core = { path = "crates/organize-rs_core" }
clap = { version = "4", features = ["derive", "env", "wrap_help"] }
Expand Down Expand Up @@ -55,6 +64,7 @@ walkdir.workspace = true
serde_yaml.workspace = true
toml.workspace = true
abscissa_core.workspace = true
rhai = { version = "1.14.0", features = ["serde"] }


[dev-dependencies]
Expand Down
13 changes: 10 additions & 3 deletions crates/organize-rs_core/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod aliases;
pub mod filters;

// Generated from py-organize
// pub mod py_organize;
pub mod py_organize;

use serde::{Deserialize, Serialize};
use std::path::PathBuf;
Expand Down Expand Up @@ -221,6 +221,13 @@ impl OrganizeTargets {
matches!(self, Self::Dirs)
}
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct OrganizeLocation {
path: String,
max_depth: Option<u64>,
}

/// [`OrganizeRule`] contains a list of objects with the required keys
/// "locations" and "actions". One config can have many [`OrganizeRule`]s.
#[derive(Debug, Clone, Deserialize, Serialize)]
Expand All @@ -233,7 +240,7 @@ pub struct OrganizeRule {
/// the folders, not on files
targets: OrganizeTargets,
/// list of locations
locations: Vec<String>,
locations: Vec<OrganizeLocation>,
/// whether to recurse into subfolders of all locations
#[serde(rename = "subfolders")]
recursive: Recurse,
Expand Down Expand Up @@ -280,7 +287,7 @@ impl OrganizeRule {
self.name.as_ref()
}

pub fn locations(&self) -> &[String] {
pub fn locations(&self) -> &[OrganizeLocation] {
self.locations.as_ref()
}
}
Loading

0 comments on commit 60df64e

Please sign in to comment.