### Build and Install Kondo from Source (Rust) Source: https://github.com/tbillington/kondo/blob/master/README.md Clones the Kondo repository and installs the CLI using Cargo, Rust's package manager. Requires Rust to be installed. ```bash git clone https://github.com/tbillington/kondo.git cargo install --path kondo/kondo ``` -------------------------------- ### Install Kondo via Homebrew (macOS/Linux) Source: https://github.com/tbillington/kondo/blob/master/README.md Installs the Kondo CLI using the Homebrew package manager. ```bash brew install kondo ``` -------------------------------- ### Build and Install Kondo UI from Source (Rust) Source: https://github.com/tbillington/kondo/blob/master/README.md Clones the Kondo repository and installs the GUI application using Cargo. Requires Rust and potentially platform-specific dependencies. ```bash git clone https://github.com/tbillington/kondo.git cargo install --path kondo/kondo-ui ``` -------------------------------- ### Install Kondo via Winget (Windows) Source: https://github.com/tbillington/kondo/blob/master/README.md Installs the Kondo CLI using the Windows Package Manager. ```powershell winget install kondo ``` -------------------------------- ### Install Kondo UI via Pacman (Arch Linux) Source: https://github.com/tbillington/kondo/blob/master/README.md Installs the Kondo GUI application using the Pacman package manager on Arch Linux. ```bash pacman -S kondo-ui ``` -------------------------------- ### Install Kondo via Pacman (Arch Linux) Source: https://github.com/tbillington/kondo/blob/master/README.md Installs the Kondo CLI using the Pacman package manager on Arch Linux. ```bash pacman -S kondo ``` -------------------------------- ### Install Kondo via MacPorts Source: https://github.com/tbillington/kondo/blob/master/README.md Installs the Kondo CLI using the MacPorts package manager. ```bash sudo port install kondo ``` -------------------------------- ### Install Kondo UI via Winget (Windows) Source: https://github.com/tbillington/kondo/blob/master/README.md Installs the Kondo GUI application using the Windows Package Manager. ```powershell winget install kondo-ui ``` -------------------------------- ### Kondo CLI Usage Examples Source: https://context7.com/tbillington/kondo/llms.txt Common command-line operations for scanning, cleaning, and filtering projects. ```bash # Scan current directory interactively kondo # Scan specific directories kondo ~/projects ~/code/work # Clean all projects without confirmation kondo --all ~/projects # Only show projects not modified in the last 3 months kondo --older 3M ~/projects # Quiet mode with automatic cleaning (no output except summary) kondo -q --all ~/projects # Very quiet mode (no output at all) kondo -qq --all ~/projects # Ignore specific directories during scan kondo -I node_modules -I .git ~/projects # Dry run - list what would be cleaned without deleting kondo --dry-run ~/projects # Follow symbolic links during scan kondo -L ~/projects # Stay on the same filesystem (don't cross mount points) kondo --same-filesystem ~/projects # Generate shell completions kondo --completions bash > kondo.bash kondo --completions zsh > _kondo kondo --completions fish > kondo.fish # Age filter time units: # m = minutes, h = hours, d = days, w = weeks, M = months, y = years kondo -o 2w # Projects older than 2 weeks kondo -o 6M # Projects older than 6 months kondo -o 1y # Projects older than 1 year ``` -------------------------------- ### Get Project Last Modified Time in Rust Source: https://context7.com/tbillington/kondo/llms.txt Retrieves the most recent modification time of files within a project to assist with filtering. ```rust use kondo_lib::{scan, print_elapsed, ScanOptions}; use std::path::Path; use std::time::SystemTime; fn main() { let options = ScanOptions { follow_symlinks: false, same_file_system: false, }; let search_path = Path::new("/home/user/projects"); for result in scan(&search_path, &options) { if let Ok(project) = result { match project.last_modified(&options) { Ok(modified_time) => { if let Ok(elapsed) = modified_time.elapsed() { let elapsed_str = print_elapsed(elapsed.as_secs()); println!("{} - last modified {}", project.name(), elapsed_str); } } Err(e) => eprintln!("Error getting modified time: {}", e), } } } } // Output: // /home/user/projects/my-rust-app - last modified 2 days ago // /home/user/projects/old-project - last modified 6 months ago // /home/user/projects/web-frontend - last modified 3 hours ago ``` -------------------------------- ### Build Kondo UI Source: https://github.com/tbillington/kondo/blob/master/README.md Navigate to the 'kondo-ui' directory first. Then use 'cargo build' to compile the kondo-ui GUI. Run 'cargo run' to execute it. ```bash cd kondo-ui cargo build ``` ```bash cd kondo-ui cargo run ``` -------------------------------- ### Build Kondo CLI Source: https://github.com/tbillington/kondo/blob/master/README.md Use 'cargo build' to compile the kondo CLI. Run 'cargo run' to execute it directly from the project root. ```bash cargo build ``` ```bash cargo run ``` -------------------------------- ### Calculate Project Size and Breakdown Source: https://context7.com/tbillington/kondo/llms.txt Use size and size_dirs to determine total artifact disk usage and detailed directory-level breakdowns. ```rust use kondo_lib::{scan, pretty_size, ScanOptions}; use std::path::Path; fn main() { let options = ScanOptions { follow_symlinks: false, same_file_system: false, }; let search_path = Path::new("/home/user/projects"); for result in scan(&search_path, &options) { if let Ok(project) = result { // Get total artifact size let total_size = project.size(&options); // Get detailed size breakdown let size_info = project.size_dirs(&options); println!("{} ({})", project.name(), project.type_name()); println!(" Artifact size: {}", pretty_size(size_info.artifact_size)); println!(" Non-artifact size: {}", pretty_size(size_info.non_artifact_size)); for (dir_name, size, is_artifact) in &size_info.dirs { let marker = if *is_artifact { "[artifact]" } else { "" }; println!(" {} {} {}", dir_name, pretty_size(*size), marker); } } } } // Output: // /home/user/projects/my-rust-app (Cargo) // Artifact size: 1.2GiB // Non-artifact size: 45.3MiB // target 1.2GiB [artifact] // src 45.3MiB ``` -------------------------------- ### Run Kondo with Time Filter (Shorthand) Source: https://github.com/tbillington/kondo/blob/master/README.md Shorthand for filtering projects by modification time using Kondo CLI. ```bash kondo -o3M ``` -------------------------------- ### Clean Project Artifacts in Rust Source: https://context7.com/tbillington/kondo/llms.txt Demonstrates cleaning project artifacts using the Project struct or a direct path string. ```rust use kondo_lib::{scan, clean, pretty_size, ScanOptions}; use std::path::Path; fn main() { let options = ScanOptions { follow_symlinks: false, same_file_system: false, }; // Method 1: Clean via Project struct let search_path = Path::new("/home/user/projects"); for result in scan(&search_path, &options) { if let Ok(project) = result { let size_before = project.size(&options); println!("Cleaning {} - freeing {}", project.name(), pretty_size(size_before) ); // Delete all artifact directories project.clean(); } } // Method 2: Clean a specific project path directly if let Err(e) = clean("/home/user/projects/my-rust-app") { eprintln!("Error cleaning project: {}", e); } } // Output: // Cleaning /home/user/projects/my-rust-app - freeing 1.2GiB // Cleaning /home/user/projects/web-frontend - freeing 856.4MiB ``` -------------------------------- ### Run Kondo with Time Filter (Older Projects) Source: https://github.com/tbillington/kondo/blob/master/README.md Executes the Kondo CLI to clean projects that haven't been modified for at least the specified duration (e.g., 3 months). ```bash kondo --older 3M ``` -------------------------------- ### Scan Directories for Projects Source: https://context7.com/tbillington/kondo/llms.txt Use the scan function to recursively discover projects within a directory. Configure behavior using ScanOptions to control symlink following and filesystem boundaries. ```rust use kondo_lib::{scan, ScanOptions, Project}; use std::path::Path; fn main() { let options = ScanOptions { follow_symlinks: false, // Don't follow symbolic links same_file_system: true, // Stay on the same filesystem }; let search_path = Path::new("/home/user/projects"); for result in scan(&search_path, &options) { match result { Ok(project) => { println!("Found {} project at: {}", project.type_name(), project.name() ); } Err(_) => eprintln!("Error scanning directory"), } } } // Output: // Found Cargo project at: /home/user/projects/my-rust-app // Found Node project at: /home/user/projects/web-frontend // Found Maven project at: /home/user/projects/java-backend ``` -------------------------------- ### Define Supported Project Types Source: https://context7.com/tbillington/kondo/llms.txt Lists the project types supported by Kondo and their associated artifact directories. ```rust use kondo_lib::ProjectType; // All supported project types and their detection files/artifact directories: // // ProjectType::Cargo - Cargo.toml -> target/, .xwin-cache/ // ProjectType::Node - package.json -> node_modules/, .angular/ // ProjectType::Unity - Assembly-CSharp.csproj -> Library/, Temp/, Obj/, Logs/, etc. // ProjectType::Stack - stack.yaml -> .stack-work/ // ProjectType::Cabal - cabal.project -> dist-newstyle/ // ProjectType::SBT - build.sbt -> target/, project/target/ // ProjectType::Maven - pom.xml -> target/ // ProjectType::Gradle - build.gradle -> build/, .gradle/ // ProjectType::CMake - CMakeLists.txt -> build/, cmake-build-debug/, cmake-build-release/ // ProjectType::Unreal - *.uproject -> Binaries/, Build/, Saved/, etc. // ProjectType::Jupyter - *.ipynb -> .ipynb_checkpoints/ // ProjectType::Python - *.py -> __pycache__/, .pytest_cache/, .mypy_cache/, etc. // ProjectType::Pixi - pixi.toml -> .pixi/ // ProjectType::Composer - composer.json -> vendor/ // ProjectType::Pub - pubspec.yaml -> build/, .dart_tool/, etc. // ProjectType::Elixir - mix.exs -> _build/, .elixir-tools/, .elixir_ls/ // ProjectType::Swift - Package.swift -> .build/, .swiftpm/ // ProjectType::Zig - build.zig -> zig-cache/, .zig-cache/, zig-out/ // ProjectType::Godot4 - project.godot -> .godot/ // ProjectType::Dotnet - *.csproj/*.fsproj -> bin/, obj/ // ProjectType::Turborepo - turbo.json -> .turbo/ // ProjectType::Terraform - .terraform.lock.hcl -> .terraform/ // ProjectType::Cocoapods - Podfile -> Pods/ ``` -------------------------------- ### Run Kondo on Specific Directories Source: https://github.com/tbillington/kondo/blob/master/README.md Executes the Kondo CLI to clean specified project directories. Multiple paths can be provided. ```bash kondo code/my_project code/my_project_2 ``` -------------------------------- ### Format Sizes and Time in Rust Source: https://context7.com/tbillington/kondo/llms.txt Utility functions for converting raw bytes and seconds into human-readable strings. ```rust use kondo_lib::{pretty_size, print_elapsed}; fn main() { // Format file sizes println!("{}", pretty_size(1024)); // "1.0KiB" println!("{}", pretty_size(1_048_576)); // "1.0MiB" println!("{}", pretty_size(1_073_741_824)); // "1.0GiB" println!("{}", pretty_size(5_368_709_120)); // "5.0GiB" // Format elapsed time println!("{}", print_elapsed(30)); // "30 seconds ago" println!("{}", print_elapsed(3600)); // "60 minutes ago" println!("{}", print_elapsed(86400)); // "24 hours ago" println!("{}", print_elapsed(604800)); // "7 days ago" println!("{}", print_elapsed(2592000)); // "4 weeks ago" println!("{}", print_elapsed(31536000)); // "12 months ago" } ``` -------------------------------- ### Run Kondo in Current Directory Source: https://github.com/tbillington/kondo/blob/master/README.md Executes the Kondo CLI to clean directories in the current working directory. Use with caution as it performs deletions. ```bash kondo ``` -------------------------------- ### Retrieve Project Artifact Directories Source: https://context7.com/tbillington/kondo/llms.txt The artifact_dirs method identifies specific folders containing build artifacts for a given project type. ```rust use kondo_lib::{Project, ProjectType}; use std::path::PathBuf; fn main() { // For a Cargo (Rust) project let cargo_project = Project { project_type: ProjectType::Cargo, path: PathBuf::from("/home/user/my-rust-project"), }; println!("Cargo artifact dirs: {:?}", cargo_project.artifact_dirs()); // Output: ["target", ".xwin-cache"] // For a Node.js project let node_project = Project { project_type: ProjectType::Node, path: PathBuf::from("/home/user/my-node-app"), }; println!("Node artifact dirs: {:?}", node_project.artifact_dirs()); // Output: ["node_modules", ".angular"] // For a Python project let python_project = Project { project_type: ProjectType::Python, path: PathBuf::from("/home/user/my-python-app"), }; println!("Python artifact dirs: {:?}", python_project.artifact_dirs()); // Output: [".mypy_cache", ".nox", ".pytest_cache", ".ruff_cache", ".tox", "__pycache__", "__pypackages__"] } ``` -------------------------------- ### Calculate Directory Size Source: https://context7.com/tbillington/kondo/llms.txt Uses dir_size to compute the total size of a directory tree, with options to control symlink following and filesystem scope. ```rust use kondo_lib::{dir_size, pretty_size, ScanOptions}; use std::path::Path; fn main() { let options = ScanOptions { follow_symlinks: false, same_file_system: false, }; let node_modules = Path::new("/home/user/project/node_modules"); let target_dir = Path::new("/home/user/rust-project/target"); let nm_size = dir_size(&node_modules, &options); let target_size = dir_size(&target_dir, &options); println!("node_modules: {}", pretty_size(nm_size)); println!("target: {}", pretty_size(target_size)); } // Output: // node_modules: 856.4MiB // target: 1.2GiB ``` -------------------------------- ### Canonicalize Paths Source: https://context7.com/tbillington/kondo/llms.txt Resolves relative paths against a base directory using path_canonicalise, while returning absolute paths unchanged. ```rust use kondo_lib::path_canonicalise; use std::path::{Path, PathBuf}; fn main() { let base = Path::new("/home/user"); // Resolve relative path let relative = PathBuf::from("projects/my-app"); match path_canonicalise(base, relative) { Ok(path) => println!("Resolved: {}", path.display()), Err(e) => eprintln!("Error: {}", e), } // Output: Resolved: /home/user/projects/my-app // Absolute paths are returned as-is let absolute = PathBuf::from("/var/www/project"); match path_canonicalise(base, absolute) { Ok(path) => println!("Absolute: {}", path.display()), Err(e) => eprintln!("Error: {}", e), } // Output: Absolute: /var/www/project } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.