cargo-run 0.5.0

A powerful, fast, and developer-friendly CLI tool for managing project scripts in Rust. Think npm scripts, make, or just — but built specifically for the Rust ecosystem.
Documentation
//! This module provides the functionality to initialize a `Scripts.toml` file.

use std::{fs, io};
use colored::*;
use emoji::symbols;

/// Initialize a `Scripts.toml` file in the current directory.
///
/// If the file already exists, it prompts the user for confirmation to replace it.
/// The function creates a default `Scripts.toml` file if the user agrees.
///
/// # Arguments
///
/// * `file_path` - Optional path to the Scripts.toml file. Defaults to "Scripts.toml" if None.
///
/// # Panics
///
/// This function will panic if it fails to read user input or write to the `Scripts.toml` file.
pub fn init_script_file(file_path: Option<&str>) {
    let file_path = file_path.unwrap_or("Scripts.toml");
    if fs::metadata(file_path).is_ok() {
        println!("{}  [ {} ] already exists. Do you want to replace it? ({}/{})", symbols::warning::WARNING.glyph, file_path.yellow(), "y".green(), "n".red());
        let mut input = String::new();
        io::stdin().read_line(&mut input).expect("Failed to read input");
        if input.trim().to_lowercase() != "y" {
            println!("Operation cancelled.");
            return;
        }
    }
    let default_content = r#"
[global_env]

[scripts]
dev = "cargo run"
build = { command = "cargo build", env = { RUST_LOG = "info" } }
release = "cargo build --release"
test = { command = "cargo test", env = { RUST_LOG = "warn" } }
doc = "cargo doc --no-deps --open"
"#;
    fs::write(file_path, default_content).expect("Failed to write Scripts.toml");
    println!("{}  [ {} ] has been created.", symbols::other_symbol::CHECK_MARK.glyph, "Scripts.toml".green());
}