fixed formatting

This commit is contained in:
glitchySid
2025-12-30 02:10:00 +05:30
parent 33784d8f1d
commit 2211057e4f
14 changed files with 55 additions and 58 deletions

View File

@@ -1,11 +1,11 @@
use colored::*;
use futures::future::join_all;
use crate::cli::Args;
use crate::settings::Config;
use crate::files::{execute_move, FileBatch, is_text_file, read_file_sample};
use crate::files::{FileBatch, execute_move, is_text_file, read_file_sample};
use crate::gemini::GeminiClient;
use crate::models::OrganizationPlan;
use crate::settings::Config;
use crate::storage::{Cache, UndoLog};
use colored::*;
use futures::future::join_all;
use std::path::PathBuf;
use std::sync::Arc;
@@ -137,13 +137,15 @@ pub async fn handle_organization(
);
let client_arc: Arc<GeminiClient> = Arc::new(client);
let semaphore: Arc<tokio::sync::Semaphore> = Arc::new(tokio::sync::Semaphore::new(args.max_concurrent));
let semaphore: Arc<tokio::sync::Semaphore> =
Arc::new(tokio::sync::Semaphore::new(args.max_concurrent));
let tasks: Vec<_> = plan
.files
.iter_mut()
.zip(batch.paths.iter())
.map(|(file_category, path): (&mut crate::models::FileCategory, &PathBuf)| {
.map(
|(file_category, path): (&mut crate::models::FileCategory, &PathBuf)| {
let client: Arc<GeminiClient> = Arc::clone(&client_arc);
let filename: String = file_category.filename.clone();
let category: String = file_category.category.clone();
@@ -165,7 +167,8 @@ pub async fn handle_organization(
String::new()
}
}
})
},
)
.collect();
let sub_categories: Vec<String> = join_all(tasks).await;

View File

@@ -1,14 +1,10 @@
use colored::*;
use crate::models::OrganizationPlan;
use crate::storage::UndoLog;
use colored::*;
use std::io;
use std::{ffi::OsStr, fs, path::Path};
pub fn execute_move(
base_path: &Path,
plan: OrganizationPlan,
mut undo_log: Option<&mut UndoLog>,
) {
pub fn execute_move(base_path: &Path, plan: OrganizationPlan, mut undo_log: Option<&mut UndoLog>) {
println!("\n{}", "--- EXECUTION PLAN ---".bold().underline());
if plan.files.is_empty() {

View File

@@ -1,5 +1,5 @@
use colored::*;
use crate::storage::UndoLog;
use colored::*;
use std::fs;
use std::io;
use std::path::Path;

View File

@@ -1,8 +1,8 @@
use crate::models::OrganizationPlan;
use crate::storage::Cache;
use crate::gemini::errors::GeminiError;
use crate::gemini::prompt::PromptBuilder;
use crate::gemini::types::{GeminiResponse, OrganizationPlanResponse};
use crate::models::OrganizationPlan;
use crate::storage::Cache;
use reqwest::Client;
use serde_json::json;
use std::path::Path;

View File

@@ -5,4 +5,6 @@ pub mod types;
pub use client::GeminiClient;
pub use errors::GeminiError;
pub use types::{Candidate, Content, FileCategoryResponse, GeminiResponse, OrganizationPlanResponse, Part};
pub use types::{
Candidate, Content, FileCategoryResponse, GeminiResponse, OrganizationPlanResponse, Part,
};

View File

@@ -1,5 +1,5 @@
use crate::models::{FileCategory, OrganizationPlan};
use crate::gemini::types::OrganizationPlanResponse;
use crate::models::{FileCategory, OrganizationPlan};
impl OrganizationPlanResponse {
pub fn to_organization_plan(self) -> OrganizationPlan {

View File

@@ -1,14 +1,14 @@
pub mod cli;
pub mod settings;
pub mod files;
pub mod gemini;
pub mod models;
pub mod settings;
pub mod storage;
pub use cli::Args;
pub use settings::Config;
pub use files::{FileBatch, execute_move, is_text_file, read_file_sample, undo_moves};
pub use gemini::GeminiClient;
pub use gemini::GeminiError;
pub use models::{FileCategory, FileMoveRecord, MoveStatus, OrganizationPlan};
pub use settings::Config;
pub use storage::{Cache, UndoLog};

View File

@@ -1,6 +1,9 @@
use noentropy::cli::{Args, orchestrator::{handle_organization, handle_undo}};
use noentropy::settings::{get_or_prompt_api_key, get_or_prompt_download_folder};
use clap::Parser;
use noentropy::cli::{
Args,
orchestrator::{handle_organization, handle_undo},
};
use noentropy::settings::{get_or_prompt_api_key, get_or_prompt_download_folder};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {

View File

@@ -1,7 +1,7 @@
pub mod organization;
pub mod metadata;
pub mod move_record;
pub mod organization;
pub use organization::{FileCategory, OrganizationPlan};
pub use metadata::{CacheEntry, FileMetadata};
pub use move_record::{FileMoveRecord, MoveStatus};
pub use organization::{FileCategory, OrganizationPlan};

View File

@@ -136,4 +136,3 @@ impl Default for Config {
}
}
}

View File

@@ -40,9 +40,7 @@ fn test_validate_api_key_invalid() {
#[test]
fn test_validate_folder_path_valid() {
let temp_dir = tempfile::tempdir().unwrap();
assert!(Prompter::validate_folder_path(
temp_dir.path()
));
assert!(Prompter::validate_folder_path(temp_dir.path()));
}
#[test]
@@ -52,9 +50,7 @@ fn test_validate_folder_path_invalid() {
)));
let temp_file = tempfile::NamedTempFile::new().unwrap();
assert!(!Prompter::validate_folder_path(
temp_file.path()
));
assert!(!Prompter::validate_folder_path(temp_file.path()));
}
#[test]

View File

@@ -199,4 +199,3 @@ impl Cache {
}
}
}

View File

@@ -6,8 +6,8 @@ pub use undo_log::UndoLog;
#[cfg(test)]
mod tests {
use crate::storage::{Cache, UndoLog};
use crate::models::{FileMoveRecord, MoveStatus};
use crate::storage::{Cache, UndoLog};
use std::path::PathBuf;
#[test]
@@ -79,7 +79,7 @@ mod tests {
let record = FileMoveRecord::new(
PathBuf::from("/from"),
PathBuf::from("/to"),
MoveStatus::Completed
MoveStatus::Completed,
);
assert_eq!(record.status, MoveStatus::Completed);
}

View File

@@ -179,4 +179,3 @@ impl UndoLog {
usage
}
}