### Rust API: get_or_create_project example output Source: https://context7.com/edwardjoke/lox-rs/llms.txt Example outputs for the `get_or_create_project` Rust function. For a Rust library project, it indicates that no binary is available to run. For a Rust binary project named 'my-tool', it prints the release run command. ```text // For a Rust library with src/lib.rs: // Library project detected - no binary to run // For a Rust binary with src/main.rs named "my-tool": // Run command: ./target/release/my-tool ``` -------------------------------- ### Install lox-rs from Source using Cargo Source: https://github.com/edwardjoke/lox-rs/blob/master/README.md This code snippet demonstrates how to clone the lox-rs repository, navigate into the directory, and install the tool globally using Cargo. It also shows how to build the project for local use. ```bash git clone https://github.com/EdwardJoke/lox-rs.git cd lox-rs cargo install --path . # Or use as a local tool cargo build --release target/release/lox --help ``` -------------------------------- ### Rust API: detect_project_info example output Source: https://context7.com/edwardjoke/lox-rs/llms.txt Example output from the `detect_project_info` Rust function for a Cargo project. It shows the detected project type, name, boolean flags for project types, and the corresponding development and release build commands. ```text // Output for a Cargo project with Cargo.toml: // Project type: app(bin) // Project name: lox // Is Rust: true // Is Python: false // Is Fortran: false // Build (dev): cargo build // Build (release): cargo build --release ``` -------------------------------- ### Configuration: Example lox.toml for a Rust project Source: https://context7.com/edwardjoke/lox-rs/llms.txt An example of a `lox.toml` configuration file generated for a Rust project. It specifies project type, name, version, build commands for development and release, run commands, and associated tasks like formatting and linting. It also includes environment details. ```toml [project] type = "app(bin)" name = "my-app" version = "0.1.0" [project.build] dev = "cargo build" release = "cargo build --release" [project.run] dev = "./target/debug/my-app" release = "./target/release/my-app" [project.commands] fmt = "cargo fmt" lint = "cargo check" dependency = "cargo update" [environment] os = "Linux" arch = "x86_64" rustc_version = "1.75.0" cargo_version = "1.75.0" ``` -------------------------------- ### Run lox-rs as a Local Tool with Cargo Source: https://github.com/edwardjoke/lox-rs/blob/master/README.md This command shows how to execute the lox-rs tool directly using Cargo without a global installation. It is useful for testing or using the tool in a local development workflow. ```bash cargo run -- --help ``` -------------------------------- ### Run Project in Development Mode (`lox dash`) Source: https://github.com/edwardjoke/lox-rs/blob/master/docs/commands_feature.md The `lox dash` command executes the project in development mode. If the project has not been built, it will first run `lox dev` to build it, then execute the project binary. This command is primarily shown with a Rust example. ```bash lox dash ``` -------------------------------- ### Rust API: get_or_create_project function Source: https://context7.com/edwardjoke/lox-rs/llms.txt Loads project configuration from `lox.toml` or detects and creates it if the file does not exist. The `get_or_create_project` function from `lox::projects` returns a `Project` struct. It handles library projects by printing a message and exiting. ```rust use lox::projects::get_or_create_project; #[tokio::main] async fn main() { // Reads from lox.toml if exists, otherwise detects and creates it let project = get_or_create_project().await; if project.is_library { println!("Library project detected - no binary to run"); return; } println!("Run command: {}", project.run_commands.release); } ``` -------------------------------- ### CLI: build command for release builds Source: https://context7.com/edwardjoke/lox-rs/llms.txt Builds a project in release mode. For Rust, it runs `cargo update`, `cargo fmt`, `cargo check`, and `cargo build --release`. For Python with `uv`, it executes `uv lock`, `uvx ruff check`, `uvx ruff format`, and `uv build`. For Fortran with FPM, it runs `fpm build --profile release`. ```bash # Build Rust project in release mode lox build # Executes: cargo update, cargo fmt, cargo check, cargo build --release # Build Python project with uv lox build # Executes: uv lock, uvx ruff check, uvx ruff format, uv build # Build Fortran FPM project lox build # Executes: fpm build --profile release ``` -------------------------------- ### CLI: run command for executing release executables Source: https://context7.com/edwardjoke/lox-rs/llms.txt Executes the project's executable in release mode. For Rust, it ensures the release binary exists, runs `lox build` if needed, then executes it. For Python with `uv`, it locks dependencies and runs the main script. For Fortran FPM projects, it checks for the build directory, runs `lox build`, and then executes `fpm run`. ```bash # Run Rust binary in release mode lox run # Checks if ./target/release/binary exists, runs lox build if needed, then executes binary # Run Python project with uv lox run # Executes: uv lock, then uv run main.py # Run Fortran FPM project lox run # Checks if ./build exists, runs lox build if needed, then executes fpm run ``` -------------------------------- ### Persist Project Configuration to TOML - Rust Source: https://context7.com/edwardjoke/lox-rs/llms.txt Writes project configuration, including build and run commands, to a TOML file. It takes a Project struct as input and creates or overwrites 'lox.toml'. Requires the 'lox::projects' module. ```rust use lox::projects::{Project, BuildCommands, RunCommands, write_project_to_toml}; let project = Project { project_type: "fpm".to_string(), name: "fortran-sim".to_string(), version: "0.1.0".to_string(), is_library: false, build_commands: BuildCommands { dev: "fpm build".to_string(), release: "fpm build --profile release".to_string(), }, run_commands: RunCommands { dev: "fpm run".to_string(), release: "fpm run --profile release".to_string(), }, is_rust_project: false, is_uv_project: false, is_fortran_project: true, }; write_project_to_toml(&project); // Creates or overwrites lox.toml with project configuration ``` -------------------------------- ### CLI: dash command for running development executables Source: https://context7.com/edwardjoke/lox-rs/llms.txt Runs the project's executable in development mode. For Rust, it checks for the debug binary, runs `lox dev` if necessary, and then executes the binary. The output shows task progress and timing. ```bash # Run Rust binary in debug mode lox dash # Checks if ./target/debug/binary exists, runs lox dev if needed, then executes binary # Example output [2/2] + Run the project. - Task | ./target/debug/lox | - Task | ./target/debug/lox | Done. [TIP] + Run the project in 0.05s. [TIP] + Done the tasks in 0.15s. [TIP] + [Task End] ``` -------------------------------- ### CLI: Doctor command for project initialization Source: https://context7.com/edwardjoke/lox-rs/llms.txt Initializes project configuration using the `doctor` command. It can be run with minimal output using the `--quiet` flag. This command helps in setting up the `lox.toml` file for project management. ```bash lox doctor lox doctor --quiet ``` -------------------------------- ### Format Operating System Name for Display - Rust Source: https://context7.com/edwardjoke/lox-rs/llms.txt Formats the operating system name string for user-friendly display. It takes the OS name (e.g., 'linux', 'macos', 'windows') as input and returns a capitalized, standardized string. Requires 'lox::projects::format_os_name' and 'std::env'. ```rust use lox::projects::format_os_name; use std::env; let os = env::consts::OS; let formatted = format_os_name(os); println!("Running on: {}", formatted); // Linux -> "Linux" // macos -> "macOS" // windows -> "Windows" ``` -------------------------------- ### CLI: dev command for development builds Source: https://context7.com/edwardjoke/lox-rs/llms.txt Builds a project in development mode. For Rust projects, it executes `cargo update`, `cargo fmt`, `cargo check`, and `cargo build`. For Fortran projects, it compiles source files with `flang -g -c` and links them with `-g`. ```bash # Build Rust project in debug mode lox dev # Executes: cargo update, cargo fmt, cargo check, cargo build # Build Fortran project in debug mode lox dev # Executes: flang -g -c for each source file, then links with -g ``` -------------------------------- ### Build Project in Development Mode (`lox dev`) Source: https://github.com/edwardjoke/lox-rs/blob/master/docs/commands_feature.md The `lox dev` command builds the project in development mode. It typically involves downloading dependencies, checking the project for errors, and then compiling the project. The output indicates the progress of each step. ```bash lox dev ``` -------------------------------- ### Bash Commands for Fortran Project Builds Source: https://github.com/edwardjoke/lox-rs/blob/master/rules/flang-llvm_project.md These bash commands are used to build Fortran projects within the lox-rs environment. 'lox dev' builds in debug mode, while 'lox build' compiles in release mode. The output is placed in the 'target/dev' or 'target/release' directories respectively. ```bash lox dev # Build the project in debug mode, output at `target/dev` lox build # Build the project in release mode, output at `target/release` ``` -------------------------------- ### Run Project in Release Mode (`lox run`) Source: https://github.com/edwardjoke/lox-rs/blob/master/docs/commands_feature.md The `lox run` command executes the project in release mode. It first ensures the project is built using `lox build` (for Rust) or performs dependency locking (for Python), then runs the project. The output demonstrates distinct steps for Rust and Python projects. ```bash lox run ``` -------------------------------- ### Rust API: detect_project_info function Source: https://context7.com/edwardjoke/lox-rs/llms.txt Automatically detects project type and configuration using the `detect_project_info` function from the `lox::projects` module. It returns a `Project` struct containing details like project type, name, and build commands. This function is asynchronous and requires `tokio`. ```rust use lox::projects::detect_project_info; #[tokio::main] async fn main() { let project = detect_project_info().await; println!("Project type: {}", project.project_type); println!("Project name: {}", project.name); println!("Is Rust: {}", project.is_rust_project); println!("Is Python: {}", project.is_uv_project); println!("Is Fortran: {}", project.is_fortran_project); println!("Build (dev): {}", project.build_commands.dev); println!("Build (release): {}", project.build_commands.release); } ``` -------------------------------- ### Build Cargo Project with Lox (Bash) Source: https://github.com/edwardjoke/lox-rs/blob/master/rules/cargo_project.md Commands to build a Cargo project using Lox. 'lox dev' builds in debug mode, and 'lox build' builds in release mode. The output files are placed in the 'target' directory. ```bash lox dev # Build the project in debug mode lox build # Build the project in release mode ``` -------------------------------- ### List Available Task IDs in lox-rs Source: https://context7.com/edwardjoke/lox-rs/llms.txt Provides a comprehensive list of available predefined task IDs for Rust/Cargo, Python/uv, and Fortran projects. These IDs represent specific command-line operations that can be executed via the `execute_task_by_id` function. ```rust use lox::tasks; // Rust/Cargo tasks tasks::CARGO_UPDATE // "cargo update" tasks::CARGO_FMT // "cargo fmt" tasks::CARGO_CHECK // "cargo check" tasks::CARGO_BUILD // "cargo build" tasks::CARGO_BUILD_RELEASE // "cargo build --release" // Python/uv tasks tasks::UV_LOCK // "uv lock" tasks::UV_RUN // "uv run main.py" tasks::UV_BUILD // "uv build" tasks::UV_RUFF_CHECK // "uvx ruff check" tasks::UV_RUFF_FORMAT // "uvx ruff format" // Fortran tasks tasks::FLANG_BUILD_DEV // "flang build dev" tasks::FLANG_BUILD_RELEASE // "flang build release" tasks::FPM_BUILD_RELEASE // "fpm build --profile release" ``` ```rust #[tokio::main] async fn main() { // Example: Python project workflow println!("[1/3] Locking dependencies"); tasks::execute_task_by_id(tasks::UV_LOCK).await; println!("[2/3] Checking code quality"); tasks::execute_task_by_id(tasks::UV_RUFF_CHECK).await; tasks::execute_task_by_id(tasks::UV_RUFF_FORMAT).await; println!("[3/3] Building package"); tasks::execute_task_by_id(tasks::UV_BUILD).await; } ``` -------------------------------- ### Build Project in Release Mode (`lox build`) Source: https://github.com/edwardjoke/lox-rs/blob/master/docs/commands_feature.md The `lox build` command compiles the project in release mode, optimizing it for production. The process differs slightly for Rust and Python projects, with Rust using `cargo build --release` and Python projects utilizing `uv build` after dependency locking and linting. ```bash lox build ``` -------------------------------- ### Execute Predefined Build Tasks with lox-rs Source: https://context7.com/edwardjoke/lox-rs/llms.txt Executes predefined build and check tasks using their unique IDs. This function is asynchronous and returns a boolean indicating success. It's useful for automating common development workflows like formatting, linting, and building. ```rust use lox::tasks; #[tokio::main] async fn main() { println!("Formatting Rust code..."); let fmt_success = tasks::execute_task_by_id(tasks::CARGO_FMT).await; println!("Running linter..."); let check_success = tasks::execute_task_by_id(tasks::CARGO_CHECK).await; if fmt_success && check_success { println!("Building release..."); tasks::execute_task_by_id(tasks::CARGO_BUILD_RELEASE).await; } } ``` ```text # Output: # Formatting Rust code... # - Task | cargo fmt | # - Task | cargo fmt | Done. # Running linter... # - Task | cargo check | # - Task | cargo check | Done. # Building release... # - Task | cargo build --release | # - Task | cargo build --release | Done. ``` -------------------------------- ### Project Struct Definition and Usage in lox-rs Source: https://context7.com/edwardjoke/lox-rs/llms.txt Defines the `Project` struct which holds comprehensive information about a detected project, including its type, name, version, build and run commands, and flags for project type (Rust, uv, Fortran). It can be used in conditional logic to tailor actions based on project properties. ```rust use lox::projects::{Project, BuildCommands, RunCommands}; let project = Project { project_type: "app(bin)".to_string(), name: "cli-tool".to_string(), version: "1.0.0".to_string(), is_library: false, build_commands: BuildCommands { dev: "cargo build".to_string(), release: "cargo build --release".to_string(), }, run_commands: RunCommands { dev: "./target/debug/cli-tool".to_string(), release: "./target/release/cli-tool".to_string(), }, is_rust_project: true, is_uv_project: false, is_fortran_project: false, }; // Use in conditional logic if project.is_rust_project && !project.is_library { println!("Can run: {}", project.run_commands.release); } ``` -------------------------------- ### Detect Python uv Project using lox-rs Source: https://context7.com/edwardjoke/lox-rs/llms.txt Detects if the current directory is a Python project managed by uv. It parses pyproject.toml to find project details and provides development build and run commands. If no pyproject.toml is found, it indicates so. ```rust use lox::projects::uv::detect_uv_project; #[tokio::main] async fn main() { if let Some(project) = detect_uv_project().await { println!("Found uv project: {}", project.name); println!("Build command: {}", project.build_commands.dev); println!("Run command: {}", project.run_commands.dev); } else { println!("No pyproject.toml found"); } } ``` ```toml # Example pyproject.toml being detected [project] name = "web-scraper" version = "1.0.0" ``` ```text # Output: # Found uv project: web-scraper # Build command: uv build # Run command: uv run main.py ``` -------------------------------- ### Check Project and Environment Info (`lox doctor`) Source: https://github.com/edwardjoke/lox-rs/blob/master/docs/commands_feature.md The `lox doctor` command checks project information and environment details. It automatically detects the project type and provides a summary of build tools, language versions, and system information. The output is consistent across different project types but may highlight specific tool versions. ```bash lox doctor ``` -------------------------------- ### Detect Rust Cargo Project using lox-rs Source: https://context7.com/edwardjoke/lox-rs/llms.txt Detects if the current directory is a Rust Cargo project. It parses the Cargo.toml file to extract project details like name, version, and type. If it's a library, it indicates so; otherwise, it shows the release binary path. ```rust use lox::projects::cargo::detect_cargo_project; #[tokio::main] async fn main() { if let Some(project) = detect_cargo_project().await { println!("Found Cargo project: {}", project.name); println!("Version: {}", project.version); println!("Type: {}", project.project_type); if project.is_library { println!("This is a library crate"); } else { println!("Binary will be at: {}", project.run_commands.release); } } else { println!("No Cargo.toml found"); } } ``` ```toml # Example Cargo.toml being detected [package] name = "data-processor" version = "2.1.0" [lib] ``` ```text # Output: # Found Cargo project: data-processor # Version: 2.1.0 # Type: library(lib) # This is a library crate ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.