### Install Binary Globally using Cargo Source: https://context7.com/jacobdeichert/mask/llms.txt Installs the current project's binary globally using `cargo install`. The `--force` flag overwrites any existing installation. This command is executed via `mask link`. ```bash cargo install --force --path . ``` ```powershell [Diagnostics.Process]::Start("cargo", "install --force --path .").WaitForExit() ``` ```bash mask link # runs bash block on Linux/macOS, powershell block on Windows ``` -------------------------------- ### Cross-Platform Binary Installation Source: https://github.com/jacobdeichert/mask/blob/master/README.md Installs a binary using Cargo. Includes both a bash and a PowerShell version for cross-platform compatibility. ```bash cargo install --force --path . ``` ```powershell [Diagnostics.Process]::Start("cargo", "install --force --path .").WaitForExit() ``` -------------------------------- ### Install Mask CLI via Homebrew Source: https://context7.com/jacobdeichert/mask/llms.txt Install the Mask CLI binary using Homebrew, a popular package manager for macOS and Linux. ```sh brew install mask ``` -------------------------------- ### PHP Script Execution Source: https://github.com/jacobdeichert/mask/blob/master/README.md Example of a PHP script command that retrieves the 'name' environment variable. ```php $name = getenv("name") ?: "WORLD"; echo "Hello, " . $name . "!\n"; ``` -------------------------------- ### Install Mask CLI via Cargo Source: https://context7.com/jacobdeichert/mask/llms.txt Install the Mask CLI binary using Cargo, Rust's package manager. ```sh cargo install mask ``` -------------------------------- ### CI Script Example Source: https://context7.com/jacobdeichert/mask/llms.txt Demonstrates how to chain mask commands in a CI script, ensuring that the pipeline stops on the first failure and the exit code reflects the failed command. ```APIDOC ## ci > Run tests, lint, and format checks ```sh mask test \ && mask lint \ && mask format --check # Stops on the first failure; exit code matches the failed command ``` ```sh mask ci && echo "CI passed" || echo "CI failed (exit $?)" ``` ``` -------------------------------- ### Define Subcommand with Argument Source: https://github.com/jacobdeichert/mask/blob/master/README.md Defines a subcommand 'start' under the 'services' command, which accepts a 'service_name' argument. This demonstrates nested command structures. ```bash echo "Starting service $service_name" ``` -------------------------------- ### Swift Script Execution Source: https://github.com/jacobdeichert/mask/blob/master/README.md Example of a Swift script command that retrieves the 'name' environment variable. Supports Swift. ```swift import Foundation let name = ProcessInfo.processInfo.environment["name"] ?? "WORLD" print("Hello, \(name)!") ``` -------------------------------- ### Get Help for Mask Subcommands Source: https://context7.com/jacobdeichert/mask/llms.txt Use `mask --help` or `mask help ` to get detailed usage information for specific subcommands. This helps in understanding available options and arguments. ```bash mask db --help ``` ```bash mask db help seed ``` -------------------------------- ### Lua Script Execution Source: https://github.com/jacobdeichert/mask/blob/master/README.md Example of a Lua script command that retrieves the 'name' environment variable. ```lua name = os.getenv("name") print("Hello, " .. name .. "!") ``` -------------------------------- ### Define Maskfile Commands Source: https://context7.com/jacobdeichert/mask/llms.txt Example of a maskfile.md defining two simple commands: 'build' and 'clean'. H2 headings define commands, blockquotes provide descriptions, and code blocks contain scripts. ```markdown # My Project Tasks A short description of this project's tasks. ## build > Compile the project ```sh echo "Building..." cargo build --release ``` ## clean > Remove build artifacts ```bash rm -rf ./target echo "Cleaned." ``` ``` -------------------------------- ### Ruby Script Execution Source: https://github.com/jacobdeichert/mask/blob/master/README.md Example of a Ruby script command that retrieves the 'name' environment variable. Supports Ruby. ```rb name = ENV["name"] || "WORLD" puts "Hello, #{name}!" ``` -------------------------------- ### Specify a Different Maskfile Source: https://github.com/jacobdeichert/mask/blob/master/README.md Demonstrates how to use the --maskfile option to execute commands with a maskfile located at a different path. Includes a bash alias example for convenience. ```sh mask --maskfile ~/maskfile.md ``` ```bash # Call it something fun alias wask="mask --maskfile ~/maskfile.md" # You can run this from anywhere wask ``` -------------------------------- ### Link Mask Locally Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Builds mask and replaces the globally installed version with the local build for testing purposes. ```bash cargo install --force --path ./mask ``` -------------------------------- ### Node.js Script Execution Source: https://github.com/jacobdeichert/mask/blob/master/README.md Example of a Node.js script command that uses the 'name' environment variable. Supports JavaScript. ```js const { name } = process.env; console.log(`Hello, ${name}!`); ``` -------------------------------- ### Python Script Execution Source: https://github.com/jacobdeichert/mask/blob/master/README.md Example of a Python script command that retrieves the 'name' environment variable. Supports Python. ```python import os name = os.getenv("name", "WORLD") print("Hello, " + name + "!") ``` -------------------------------- ### Link Mask Locally (Windows) Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Builds mask and replaces the globally installed version with the local build for testing purposes on Windows. ```powershell [Diagnostics.Process]::Start("cargo", "install --force --path ./mask").WaitForExit() ``` -------------------------------- ### Shell Script Execution Source: https://github.com/jacobdeichert/mask/blob/master/README.md Example of a shell script command that accepts a 'name' argument. Supports various shell runtimes like sh, bash, zsh, and fish. ```zsh echo "Hello, $name!" ``` -------------------------------- ### `mask-parser` Library - `parse` Function Source: https://context7.com/jacobdeichert/mask/llms.txt Example of using the `parse` function from the `mask-parser` crate to convert maskfile markdown into a structured `Maskfile` object in Rust. ```APIDOC ## `mask-parser` Library — `parse` The `parse` function (exported from the `mask-parser` crate) converts raw maskfile markdown text into a `Maskfile` struct containing a title, description, and a tree of `Command` nodes. Each command carries its level, name, description, optional script (executor + source), subcommands, required args, optional args, and named flags. ```rust use mask_parser; fn main() { let contents = std::fs::read_to_string("maskfile.md").expect("read failed"); let maskfile = mask_parser::parse(contents); println!("Title: {}", maskfile.title); println!("Description: {}", maskfile.description); for cmd in &maskfile.commands { println!("Command: {}", cmd.name); if let Some(script) = &cmd.script { println!(" Executor: {}", script.executor); println!(" Source: {}", script.source.trim()); } for arg in &cmd.required_args { println!(" Required arg: {}", arg.name); } for flag in &cmd.named_flags { println!(" Flag: --{} (-{})", flag.long, flag.short); } for sub in &cmd.subcommands { println!(" Subcommand: {}", sub.name); } } // Serialize to JSON let json = maskfile.to_json().expect("serialization failed"); println!("{}", serde_json::to_string_pretty(&json).unwrap()); } ``` ``` -------------------------------- ### Parsing Maskfile Markdown with Rust Source: https://context7.com/jacobdeichert/mask/llms.txt Uses the `mask-parser` crate to read and parse a maskfile.md into a `Maskfile` struct. This example shows how to access the title, description, commands, arguments, and flags, and then serialize the parsed structure to JSON. ```rust use mask_parser; fn main() { let contents = std::fs::read_to_string("maskfile.md").expect("read failed"); let maskfile = mask_parser::parse(contents); println!("Title: {}", maskfile.title); println!("Description: {}", maskfile.description); for cmd in &maskfile.commands { println!("Command: {}", cmd.name); if let Some(script) = &cmd.script { println!(" Executor: {}", script.executor); println!(" Source: {}", script.source.trim()); } for arg in &cmd.required_args { println!(" Required arg: {}", arg.name); } for flag in &cmd.named_flags { println!(" Flag: --{} (-{})", flag.long, flag.short); } for sub in &cmd.subcommands { println!(" Subcommand: {}", sub.name); } } // Serialize to JSON let json = maskfile.to_json().expect("serialization failed"); println!("{}", serde_json::to_string_pretty(&json).unwrap()); } ``` -------------------------------- ### Execute Mask Command with Positional Arguments Source: https://context7.com/jacobdeichert/mask/llms.txt Shows execution of the 'greet' command with and without the optional 'greeting' argument, and how to access help. ```sh mask greet Alice # Output: Hello, Alice! mask greet Alice Howdy # Output: Howdy, Alice! mask greet --help # USAGE: # mask greet [OPTIONS] [greeting] ``` -------------------------------- ### Execute Mask Commands Source: https://context7.com/jacobdeichert/mask/llms.txt Demonstrates how to execute the 'build' and 'clean' commands defined in a maskfile.md. ```sh mask build # Output: Building... mask clean # Output: Cleaned. ``` -------------------------------- ### Execute Mask Command with Named Flags Source: https://context7.com/jacobdeichert/mask/llms.txt Demonstrates executing the 'serve' command with various flag combinations, including valid inputs and error cases for type and choices. ```sh mask serve ./public --port 8080 --env production --open # Output: Serving ./public on port 8080 (env: production) mask serve ./public --port abc # ERROR: flag `port` expects a numerical value mask serve ./public --env qa # ERROR: flag `env` expects one of ["development", "staging", "production"] ``` -------------------------------- ### Seed Database with Fixture using Mask Source: https://context7.com/jacobdeichert/mask/llms.txt Seed the database with a fixture file using the `mask db seed` command. The fixture file path is passed as an argument. ```bash echo "Seeding with $fixture" ``` ```bash mask db seed fixtures/users.json ``` -------------------------------- ### Generate Help Output with Mask CLI Source: https://github.com/jacobdeichert/mask/blob/master/README.md Demonstrates how to access help information for mask commands using -h, --help flags, or the 'help ' subcommand. ```sh mask services start -h mask services start --help mask services help start mask help services start ``` ```txt mask-services-start Start or restart a service. USAGE: mask services start [FLAGS] FLAGS: -h, --help Prints help information -V, --version Prints version information -v, --verbose Sets the level of verbosity -r, --restart Restart this service if it's already running -w, --watch Restart a service on file change ARGS: ``` -------------------------------- ### Define Maskfile with Named Flags Source: https://context7.com/jacobdeichert/mask/llms.txt Defines a 'serve' command with named flags for 'port', 'env', and 'open'. Flags can have types, choices, and descriptions. ```markdown ## serve (dir) > Start a development server **OPTIONS** * port * flags: -p --port * type: number * desc: Port to listen on * env * flags: -e --env * type: string * choices: development, staging, production * desc: Target environment * open * flags: -o --open * desc: Open browser automatically ```bash PORT=${port:-3000} ENV=${env:-development} echo "Serving $dir on port $PORT (env: $ENV)" [[ "$open" == "true" ]] && xdg-open "http://localhost:$PORT" [[ "$verbose" == "true" ]] && echo "[verbose] server started" ``` ``` -------------------------------- ### Define Maskfile with Positional Arguments Source: https://context7.com/jacobdeichert/mask/llms.txt Defines a 'greet' command with a required positional argument 'name' and an optional positional argument 'greeting'. Arguments are available as environment variables. ```markdown ## greet (name) [greeting] > Greet someone with an optional custom greeting ```bash GREETING=${greeting:-Hello} echo "$GREETING, $name!" ``` ``` -------------------------------- ### Chaining Mask Commands in CI Source: https://context7.com/jacobdeichert/mask/llms.txt Demonstrates how to chain mask commands using '&&' for sequential execution in CI pipelines. This pattern ensures that the pipeline stops on the first command failure, and the overall exit code reflects the failure. ```sh mask test \ && mask lint \ && mask format --check # Stops on the first failure; exit code matches the failed command ``` ```sh mask ci && echo "CI passed" || echo "CI failed (exit $?)" ``` -------------------------------- ### Define Basic Tasks in Maskfile.md Source: https://github.com/jacobdeichert/mask/blob/master/README.md Create a maskfile.md to define tasks. Headings define command names, blockquotes define descriptions, and code blocks define the scripts to be executed. Supports multiple scripting runtimes like sh, js, python, ruby, and php. ```markdown # Tasks For My Project ## build > Builds my project ```sh echo "building project..." ``` ## test > Tests my project You can also write documentation anywhere you want. Only certain types of markdown patterns are parsed to determine the command structure. This code block below is defined as js which means it will be ran with node. Mask also supports other scripting runtimes including python, ruby and php! ```js console.log("running tests...") ``` ``` -------------------------------- ### Build Mask from Source Source: https://context7.com/jacobdeichert/mask/llms.txt Build the Mask CLI binary from its source code using Cargo. The release binary will be located in the ./target/release/mask path. ```sh git clone https://github.com/jacobdeichert/mask cargo build --release # Binary will be at ./target/release/mask ``` -------------------------------- ### Run Mask Commands from Scripts Source: https://github.com/jacobdeichert/mask/blob/master/README.md Shows how to chain mask commands within a script for sequential execution. Utilizes the $MASK environment variable for location-agnostic script execution, especially with different maskfiles. ```sh mask install mask build mask link # $MASK also works. It's an alias variable for `mask --maskfile ` # which guarantees your scripts will still work even if they are called from # another directory. $MASK db migrate $MASK start ``` -------------------------------- ### Format Source Files Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Formats all source files in the project. If the 'check' flag is enabled, it will only report which files are not formatted correctly without modifying them. ```bash if [[ $check == "true" ]]; then cargo fmt --all -- --check else cargo fmt fi ``` -------------------------------- ### Run Mask in Development Mode Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Builds and runs mask in development mode. Use this to test changes to mask. It rebuilds on file changes if the watch flag is set. ```bash if [[ $watch == "true" ]]; then watchexec --exts rs --restart "cargo run -- $maskfile_command" else cargo run -- $maskfile_command fi ``` -------------------------------- ### Define Maskfile with Required Flags Source: https://context7.com/jacobdeichert/mask/llms.txt Defines a 'deploy' command with a required 'target' flag. Mask will exit with an error if this flag is not provided. ```markdown ## deploy > Deploy the application **OPTIONS** * target * flags: -t --target * type: string * desc: Deployment target host * required ```bash echo "Deploying to $target..." ssh $target "systemctl restart myapp" ``` ``` -------------------------------- ### Lint Project with Clippy Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Lints the project using clippy to check for common mistakes and improve code quality. ```bash cargo clippy ``` ```powershell cargo clippy ``` -------------------------------- ### Run Database Migrations with Mask Source: https://context7.com/jacobdeichert/mask/llms.txt Execute pending database migrations using the `mask db migrate` command. This is part of the database management subcommands. ```bash echo "Running migrations..." ``` ```bash mask db migrate ``` -------------------------------- ### Run All Tests (Windows) Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Runs all tests for the mask project on Windows using PowerShell. If the 'file' option is provided, it runs tests only from that specific filename. The 'verbose' flag enables linear test execution with visible logs. ```powershell param ( $file = $env:file ) $extra_args = "" $verbose = $env:verbose if ($verbose) { $extra_args = "-- --nocapture --test-threads=1" } Write-Output "Running tests..." if (!$file) { cargo test $extra_args } else { cargo test --test $file $extra_args } Write-Output "Tests passed!" ``` -------------------------------- ### Deploy a Mask Task Source: https://context7.com/jacobdeichert/mask/llms.txt Use the `mask deploy` command to deploy a task to a specified target. Ensure the target is correctly formatted. ```bash mask deploy --target prod.example.com ``` -------------------------------- ### Run All Tests Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Runs all tests for the mask project. If the 'file' option is provided, it runs tests only from that specific filename. The 'verbose' flag enables linear test execution with visible logs. ```bash extra_args="" if [[ "$verbose" == "true" ]]; then # Run tests linearly and make logs visible in output extra_args="-- --nocapture --test-threads=1" fi echo "Running tests..." if [[ -z "$file" ]]; then # Run all tests by default cargo test $extra_args else # Tests a specific integration filename cargo test --test $file $extra_args fi echo "Tests passed!" ``` -------------------------------- ### Define Maskfile with Boolean Flags Source: https://context7.com/jacobdeichert/mask/llms.txt Defines a 'test' command with custom boolean flags 'watch' and 'coverage', and utilizes the implicit '--verbose' flag. ```markdown ## test > Run the test suite **OPTIONS** * watch * flags: -w --watch * desc: Re-run tests on file change * coverage * flags: -c --coverage * desc: Emit a coverage report ```bash [[ "$verbose" == "true" ]] && echo "Verbose mode on" [[ "$watch" == "true" ]] && echo "Watch mode on" [[ "$coverage" == "true" ]] && echo "Coverage enabled" cargo test ``` ``` -------------------------------- ### Run Mask Tasks from CLI Source: https://github.com/jacobdeichert/mask/blob/master/README.md Execute defined tasks using the 'mask' command followed by the task name. This allows for easy execution of project-specific scripts. ```sh mask build mask test ``` -------------------------------- ### Run Mask with a Custom Maskfile Source: https://context7.com/jacobdeichert/mask/llms.txt Execute Mask tasks using a specific maskfile by providing the `--maskfile` flag. This is useful for managing different sets of tasks or for global utility runners. ```bash # Use a specific maskfile once mask --maskfile ~/dotfiles/tasks.md backup ``` ```bash # Create a permanent alias for a global maskfile alias gtask="mask --maskfile ~/gtasks.md" gtask backup gtask cleanup --dry-run ``` -------------------------------- ### Format Source Files (Windows) Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Formats all source files in the project on Windows using PowerShell. If the 'check' flag is enabled, it will only report which files are not formatted correctly without modifying them. ```powershell param ( $check = $env:check ) if ($check) { cargo fmt --all -- --check } else { cargo fmt } ``` -------------------------------- ### Build Release Version of Mask Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Builds a release version of the mask project. ```bash cargo build --release ``` ```powershell cargo build --release ``` -------------------------------- ### Run Mask in Development Mode (Windows) Source: https://github.com/jacobdeichert/mask/blob/master/maskfile.md Builds and runs mask in development mode on Windows using PowerShell. It rebuilds on file changes if the watch flag is set. ```powershell param ( $maskfile_command = $env:maskfile_command, $watch = $env:watch ) $cargo_cmd = "cargo run -- $maskfile_command" $extra_args = "--exts rs --restart $cargo_cmd" if ($watch) { Start-Process watchexec -ArgumentList $extra_args -NoNewWindow -PassThru } else { cargo run -- $maskfile_command } ``` -------------------------------- ### Execute Mask Command with Boolean Flags Source: https://context7.com/jacobdeichert/mask/llms.txt Shows execution of the 'test' command with the implicit '--verbose' flag and custom boolean flags '--watch' and '--coverage'. ```sh mask test -v --watch --coverage # Output: # Verbose mode on # Watch mode on # Coverage enabled ``` -------------------------------- ### Generate HTML Report using Mask Source: https://context7.com/jacobdeichert/mask/llms.txt Generates an HTML report by substituting placeholders in a template file. It uses the `$MASKFILE_DIR` environment variable to locate template and output files, and the `sed` command for substitution. ```bash TEMPLATE="$MASKFILE_DIR/templates/report.html" OUTPUT="$MASKFILE_DIR/dist/report.html" sed "s/{{DATE}}/$(date)/g" "$TEMPLATE" > "$OUTPUT" echo "Report written to $OUTPUT" ``` -------------------------------- ### Download and Process Data with Node.js Source: https://context7.com/jacobdeichert/mask/llms.txt This JavaScript snippet downloads data from a URL provided via the `url` environment variable and logs the number of bytes received. It requires the `https` module. ```javascript const https = require("https"); const { url } = process.env; https.get(url, res => { let data = ""; res.on("data", chunk => data += chunk); res.on("end", () => console.log("Received bytes:", data.length)); }); ``` ```bash mask fetch-data https://api.example.com/data ``` -------------------------------- ### Execute CI Pipeline with Mask Source: https://context7.com/jacobdeichert/mask/llms.txt Runs a sequence of Mask tasks (`test`, `lint`, `format --check`) as part of a CI pipeline. It utilizes the `$MASK` environment variable for reliable command execution. ```bash $MASK test $MASK lint $MASK format --check echo "All checks passed!" ``` ```bash # Calling from any directory still resolves paths correctly mask --maskfile ~/projects/myapp/maskfile.md ci ``` -------------------------------- ### Execute Mask Command Missing Required Flag Source: https://context7.com/jacobdeichert/mask/llms.txt Demonstrates the error message when attempting to run the 'deploy' command without providing the required 'target' flag. ```sh mask deploy # ERROR: The following required arguments were not provided: ``` -------------------------------- ### Parse and Pretty-Print JSON with Python Source: https://context7.com/jacobdeichert/mask/llms.txt This Python snippet reads a JSON file specified by the `file` environment variable, parses it, and prints it with an indentation of 2 spaces. It requires the `json` and `os` modules. ```python import json, os path = os.environ["file"] with open(path) as f: print(json.dumps(json.load(f), indent=2)) ``` ```bash mask parse-json config.json ``` -------------------------------- ### Access Automatic Help Output in Mask Source: https://context7.com/jacobdeichert/mask/llms.txt Mask automatically provides `-h`/`--help` flags and a `help ` alias for every command. This eliminates the need for manual help text generation. ```bash mask --help mask serve --help mask serve -h mask help serve ``` -------------------------------- ### Define Mask Task with Optional Arguments Source: https://github.com/jacobdeichert/mask/blob/master/README.md Define tasks that accept optional arguments by enclosing them in square brackets next to the command name. The argument's value is available as an environment variable if provided. ```markdown ## test [test_file] > Run tests ```bash if [[ -n "$test_file" ]]; then echo "Run tests in $test_file..." else echo "Running all tests...." fi ``` ``` -------------------------------- ### Chain Mask Commands with Exit Code Inheritance Source: https://github.com/jacobdeichert/mask/blob/master/README.md Illustrates how mask inherits the exit code of executed commands, enabling error handling by exiting on the first failure when chaining commands with '&&'. ```sh mask test \ && mask lint \ && mask format --check ``` -------------------------------- ### Introspect Maskfile Structure Source: https://context7.com/jacobdeichert/mask/llms.txt Use the `--introspect` flag to output the parsed command structure of a maskfile in JSON format. This is valuable for tooling and debugging. ```bash mask --introspect ``` ```json { "title": "My Project Tasks", "description": "Development tasks.", "commands": [ { "level": 2, "name": "serve", "description": "Start a development server", "script": { "executor": "bash", "source": "..." }, "subcommands": [], "required_args": [{ "name": "dir" }], "optional_args": [], "named_flags": [ { "name": "port", "short": "p", "long": "port", "takes_value": true, ... }, { "name": "verbose", "short": "v", "long": "verbose", "takes_value": false, ... } ] } ] } ``` -------------------------------- ### Define Mask Task with Named Flags and Options Source: https://github.com/jacobdeichert/mask/blob/master/README.md Define named flags for tasks using the OPTIONS section. Flags can have short (-p) and long (--port) forms, a type (string, number), and a description. The flag value is available as an environment variable. ```markdown ## serve > Serve this directory **OPTIONS** * port * flags: -p --port * type: string * desc: Which port to serve on ```sh PORT=${port:-8080} # Set a fallback port if not supplied if [[ "$verbose" == "true" ]]; then echo "Starting an http server on PORT: $PORT" fi python -m SimpleHTTPServer $PORT ``` ``` -------------------------------- ### Define Required String Flag Source: https://github.com/jacobdeichert/mask/blob/master/README.md Defines a required string flag for a command. Mask will error if this flag is not supplied by the user. ```sh ping $domain ``` -------------------------------- ### Rollback Last Migration with Mask Source: https://context7.com/jacobdeichert/mask/llms.txt Roll back the last database migration using the `mask db rollback` command. This is a straightforward database management operation. ```bash echo "Rolling back..." ``` -------------------------------- ### Define Mask Task with Positional Arguments Source: https://github.com/jacobdeichert/mask/blob/master/README.md Define tasks that accept required positional arguments by enclosing them in parentheses next to the command name. Argument names are available as environment variables within the script. ```markdown ## test (file) (test_case) > Run tests ```bash echo "Testing $test_case in $file" ``` ``` -------------------------------- ### Define String Flag with Default Value Source: https://github.com/jacobdeichert/mask/blob/master/README.md Defines a string flag with a fallback default value. Use this when a string option should have a predefined value if not explicitly provided by the user. ```bash COLOR=${color:-RED} # Fallback to RED if not supplied echo "Color selected = '$COLOR'" ``` -------------------------------- ### Conditional Logic with Boolean Flags Source: https://github.com/jacobdeichert/mask/blob/master/README.md Executes commands conditionally based on the presence of boolean flags like 'watch' or 'verbose'. The 'verbose' flag is automatically injected by mask. ```bash [[ "$watch" == "true" ]] && echo "Starting in watch mode..." [[ "$verbose" == "true" ]] && echo "Running with extra logs..." ``` -------------------------------- ### Define Mask Task with Number Type Flag Source: https://github.com/jacobdeichert/mask/blob/master/README.md Define a flag with type 'number' to enable automatic numerical validation by mask. If the provided value is not a valid number, mask will exit with an error. ```markdown ## purchase (price) > Calculate the total price of something. **OPTIONS** * tax * flags: -t --tax * type: number * desc: What's the tax? ```sh TAX=${tax:-1} # Fallback to 1 if not supplied echo "Total: $(($price * $TAX))" ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.