Skip to content

Commit 836e8e0

Browse files
committed
workspace_tools: cleaning
1 parent d2e99fc commit 836e8e0

27 files changed

+1110
-13336
lines changed

module/core/workspace_tools/Cargo.toml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,39 @@ documentation = "https://docs.rs/workspace_tools"
1111
repository = "https://github.com/Wandalen/workspace_tools"
1212
homepage = "https://github.com/Wandalen/workspace_tools"
1313
description = """
14-
Universal workspace-relative path resolution for any Rust project. Provides consistent, reliable path management regardless of execution context or working directory.
14+
Reliable workspace-relative path resolution for Rust projects. Automatically finds your workspace root and provides consistent file path handling regardless of execution context.
1515
"""
16-
categories = [ "development-tools", "filesystem" ]
17-
keywords = [ "workspace", "path", "resolution", "build-tools", "cross-platform" ]
16+
categories = [ "filesystem", "development-tools" ]
17+
keywords = [ "workspace", "path", "cargo", "filesystem", "build-tools" ]
1818

1919
[lints]
2020
workspace = true
2121

2222
[package.metadata.docs.rs]
23-
features = [ "full" ]
23+
features = [ "serde", "glob", "secrets", "validation" ]
2424
all-features = false
2525

2626
[features]
27-
default = [ "full" ]
28-
full = [ "enabled", "glob", "secret_management", "cargo_integration", "serde_integration", "stress", "integration" ]
29-
enabled = [ "dep:tempfile" ]
27+
default = [ "serde" ]
28+
serde = [ "dep:serde", "dep:serde_json", "dep:serde_yaml" ]
3029
glob = [ "dep:glob" ]
31-
secret_management = []
32-
cargo_integration = [ "dep:cargo_metadata", "dep:toml" ]
33-
serde_integration = [ "dep:serde", "dep:serde_json", "dep:serde_yaml" ]
34-
stress = []
35-
integration = []
30+
secrets = []
31+
validation = [ "dep:jsonschema", "dep:schemars" ]
32+
testing = [ "dep:tempfile" ]
3633

3734
[dependencies]
35+
# Core dependencies (always available)
36+
cargo_metadata = { workspace = true }
37+
toml = { workspace = true, features = [ "preserve_order" ] }
38+
39+
# Optional dependencies
3840
glob = { workspace = true, optional = true }
3941
tempfile = { workspace = true, optional = true }
40-
cargo_metadata = { workspace = true, optional = true }
41-
toml = { workspace = true, features = [ "preserve_order" ], optional = true }
4242
serde = { workspace = true, features = [ "derive" ], optional = true }
4343
serde_json = { workspace = true, optional = true }
4444
serde_yaml = { workspace = true, optional = true }
45+
jsonschema = { version = "0.20", optional = true }
46+
schemars = { version = "0.8", optional = true }
4547

4648
[dev-dependencies]
4749
# Test utilities - using minimal local dependencies only

module/core/workspace_tools/examples/010_cargo_and_serde_integration.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ fn main() -> Result< (), Box< dyn core::error::Error > >
6262
{
6363
println!( "🚀 Cargo Integration and Serde Integration Demo\n" );
6464

65-
// demonstrate cargo integration
66-
#[ cfg( feature = "cargo_integration" ) ]
65+
// demonstrate cargo integration (always available)
6766
cargo_integration_demo();
6867

6968
// demonstrate serde integration
70-
#[ cfg( feature = "serde_integration" ) ]
69+
#[ cfg( feature = "serde" ) ]
7170
serde_integration_demo()?;
7271

7372
Ok( () )
@@ -290,9 +289,9 @@ fn serde_integration_demo() -> Result< (), Box< dyn core::error::Error > >
290289
Ok( () )
291290
}
292291

293-
#[ cfg( not( any( feature = "cargo_integration", feature = "serde_integration" ) ) ) ]
292+
#[ cfg( not( feature = "serde" ) ) ]
294293
fn main()
295294
{
296-
println!( "🔧 This example requires cargo_integration and/or serde_integration features." );
297-
println!( " Run with: cargo run --example 010_cargo_and_serde_integration --features full" );
295+
println!( "🔧 This example requires serde feature (enabled by default)." );
296+
println!( " Run with: cargo run --example 010_cargo_and_serde_integration --features serde" );
298297
}

module/core/workspace_tools/readme.md

Lines changed: 17 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -131,90 +131,41 @@ your-project/
131131

132132
---
133133

134-
## 🎭 Advanced Features
134+
## 🔧 Optional Features
135135

136-
`workspace_tools` is packed with powerful, optional features. Enable them in your `Cargo.toml` as needed.
136+
Enable additional functionality as needed in your `Cargo.toml`:
137137

138-
<details>
139-
<summary><strong>🔧 Seamless Serde Integration (`serde_integration`)</strong></summary>
140-
141-
Eliminate boilerplate for loading `.toml`, `.json`, and `.yaml` files.
142-
143-
**Enable:** `cargo add serde` and add `workspace_tools = { workspace = true, features = ["serde_integration"] }` to `Cargo.toml`.
138+
**Serde Integration** (`serde`) - *enabled by default*
139+
Load `.toml`, `.json`, and `.yaml` files directly into structs.
144140

145141
```rust
146-
use serde::Deserialize;
147-
use workspace_tools::workspace;
148-
149142
#[ derive( Deserialize ) ]
150-
struct AppConfig
151-
{
152-
name : String,
153-
port : u16,
154-
}
155-
156-
let ws = workspace()?;
157-
158-
// Automatically finds and parses `config/app.{toml,yaml,json}`.
159-
let config : AppConfig = ws.load_config( "app" )?;
160-
println!( "Running '{}' on port {}", config.name, config.port );
143+
struct AppConfig { name: String, port: u16 }
161144

162-
// Load and merge multiple layers (e.g., base + production).
163-
let final_config : AppConfig = ws.load_config_layered( &[ "base", "production" ] )?;
164-
165-
// Partially update a configuration file on disk.
166-
let updates = serde_json::json!( { "port": 9090 } );
167-
let updated_config : AppConfig = ws.update_config( "app", updates )?;
145+
let config: AppConfig = workspace()?.load_config( "app" )?;
168146
```
169147

170-
</details>
171-
172-
<details>
173-
<summary><strong>🔍 Powerful Resource Discovery (`glob`)</strong></summary>
174-
175-
Find files anywhere in your workspace using glob patterns.
176-
177-
**Enable:** Add `workspace_tools = { workspace = true, features = ["glob"] }` to `Cargo.toml`.
148+
**Resource Discovery** (`glob`)
149+
Find files with glob patterns like `src/**/*.rs`.
178150

179151
```rust
180-
use workspace_tools::workspace;
181-
182-
let ws = workspace()?;
183-
184-
// Find all Rust source files recursively.
185-
let rust_files = ws.find_resources( "src/**/*.rs" )?;
186-
187-
// Intelligently find a config file, trying multiple extensions.
188-
let db_config = ws.find_config( "database" )?; // Finds config/database.toml, .yaml, etc.
152+
let rust_files = workspace()?.find_resources( "src/**/*.rs" )?;
189153
```
190154

191-
</details>
192-
193-
<details>
194-
<summary><strong>🔒 Secure Secret Management (`secret_management`)</strong></summary>
195-
196-
Load secrets from files in a dedicated, git-ignored `.secret/` directory, with fallbacks to environment variables.
197-
198-
**Enable:** Add `workspace_tools = { workspace = true, features = ["secret_management"] }` to `Cargo.toml`.
199-
200-
```
201-
// .gitignore
202-
.*
203-
// .secret/-secrets.sh
204-
API_KEY="your-super-secret-key"
205-
```
155+
**Secret Management** (`secrets`)
156+
Load secrets from `.secret/` directory with environment fallbacks.
206157

207158
```rust
208-
use workspace_tools::workspace;
159+
let api_key = workspace()?.load_secret_key( "API_KEY", "-secrets.sh" )?;
160+
```
209161

210-
let ws = workspace()?;
162+
**Config Validation** (`validation`)
163+
Schema-based validation for configuration files.
211164

212-
// Loads API_KEY from .secret/-secrets.sh, or falls back to the environment.
213-
let api_key = ws.load_secret_key( "API_KEY", "-secrets.sh" )?;
165+
```rust
166+
let config: AppConfig = workspace()?.load_config_with_validation( "app" )?;
214167
```
215168

216-
</details>
217-
218169
---
219170

220171
## 🛠️ Built for the Real World
@@ -286,15 +237,6 @@ graph TD
286237

287238
---
288239

289-
## 🚧 Vision & Roadmap
290-
291-
`workspace_tools` is actively developed. Our vision is to make workspace management a solved problem in Rust. Upcoming features include:
292-
293-
* **Project Scaffolding**: A powerful `cargo workspace-tools init` command to create new projects from templates.
294-
* **Configuration Validation**: Schema-based validation to catch config errors before they cause panics.
295-
* **Async & Hot-Reloading**: Full `tokio` integration for non-blocking file operations and live configuration reloads.
296-
* **Official CLI Tool**: A `cargo workspace-tools` command for managing your workspace from the terminal.
297-
* **IDE Integration**: Rich support for VS Code and RustRover to bring workspace-awareness directly into your editor.
298240

299241
## 🤝 Contributing
300242

0 commit comments

Comments
 (0)