diff --git a/Cargo.lock b/Cargo.lock index 9cc0d6b..e85623b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -720,6 +720,7 @@ dependencies = [ "anyhow", "clap", "dt_core", + "indicatif", "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index 3abbc87..220bf13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,3 +25,4 @@ swc_core = { version = "0.104.2", features = ["common", "ecma_ast", "ecma swc_ecma_parser = { version = "0.150.0", features = ["typescript"] } clap = { version = "4.5", features = ["derive"] } rusqlite = { version = "0.32.1", features = ["bundled"] } +indicatif = "0.17.8" \ No newline at end of file diff --git a/crates/api_server/src/main.rs b/crates/api_server/src/main.rs index 7be3b51..5a886fa 100644 --- a/crates/api_server/src/main.rs +++ b/crates/api_server/src/main.rs @@ -26,6 +26,8 @@ struct Info { exact_match: bool, } +// Current implementation is mimick version of the trace with in-memory graph. +// We can refactor it after the database feature gets validated. #[get("/search")] async fn search( data: web::Data, diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index be5ddc4..28c009a 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -10,5 +10,6 @@ version = "0.1.0" anyhow = { workspace = true } clap = { workspace = true } serde_json = { workspace = true } +indicatif = { workspace = true } dt_core = { version = "0.1.0", path = "../dt_core" } \ No newline at end of file diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 0375a81..b124bb2 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -15,6 +15,7 @@ use dt_core::{ route::{collect_route_dependency, Route, SymbolToRoutes}, scheduler::ParserCandidateScheduler, }; +use indicatif::{ProgressBar, ProgressStyle}; use std::{ collections::{HashMap, HashSet}, fs::File, @@ -156,6 +157,13 @@ fn parse_and_export_project_to_database( .context("add translation to project")?; let mut scheduler = ParserCandidateScheduler::new(&project_root); + let bar = ProgressBar::new(scheduler.get_total_remaining_candidate_count() as u64); + bar.set_style( + ProgressStyle::with_template( + "[{elapsed_precise}] {bar:40.cyan/blue} {pos:>7}/{len:7} {msg}", + )? + .progress_chars("##-"), + ); loop { match scheduler.get_one_candidate() { Some(c) => { @@ -198,11 +206,12 @@ fn parse_and_export_project_to_database( ))?; scheduler.mark_candidate_as_parsed(c); + bar.inc(1); } None => break, } } - + bar.finish_with_message("all modules parsed 🌲"); Ok(()) } @@ -562,7 +571,8 @@ impl Project { ))?; } Err(_) => { - println!("try to add translation for symbol {}, but translation {} doesn't exist", symbol_name, key); + // you can uncomment this to debug + // println!("try to add translation for symbol {}, but translation {} doesn't exist", symbol_name, key); } } } diff --git a/crates/demo/Cargo.toml b/crates/demo/Cargo.toml index 288be90..67c7710 100644 --- a/crates/demo/Cargo.toml +++ b/crates/demo/Cargo.toml @@ -7,12 +7,12 @@ version = "0.1.0" [dependencies] -anyhow = { workspace = true } -clap = { workspace = true } +anyhow = { workspace = true } +clap = { workspace = true } +indicatif = { workspace = true } umya-spreadsheet = "1.2.3" dialoguer = { version = "0.11.0", features = ["history"] } -indicatif = "0.17.8" console = "0.15.8" rand = "0.8.5" diff --git a/crates/demo/src/main.rs b/crates/demo/src/main.rs index 6c7ef6c..971f4d8 100644 --- a/crates/demo/src/main.rs +++ b/crates/demo/src/main.rs @@ -1,13 +1,8 @@ use anyhow::Context; use clap::Parser; use console::style; -use dialoguer::{theme::ColorfulTheme, BasicHistory, Confirm, Input, Select}; -use indicatif::{ProgressBar, ProgressStyle}; -use rand::distributions::Alphanumeric; -use rand::{thread_rng, Rng}; -use std::path::PathBuf; - use demo::spreadsheet::write_to_spreadsheet; +use dialoguer::{theme::ColorfulTheme, BasicHistory, Confirm, Input, Select}; use dt_core::{ graph::{depend_on_graph::DependOnGraph, used_by_graph::UsedByGraph}, parser::{collect_symbol_dependency, Input as ModuleInput}, @@ -15,6 +10,9 @@ use dt_core::{ scheduler::ParserCandidateScheduler, tracker::{DependencyTracker, TraceTarget}, }; +use indicatif::{ProgressBar, ProgressStyle}; +use rand::{distributions::Alphanumeric, thread_rng, Rng}; +use std::path::PathBuf; const SYMBOL_TYPE_SELECTIONS: [&str; 3] = ["Default Export", "Named Export", "Local Variable"];