From 471eca75ee0e934362451655329d6f0edd2536e6 Mon Sep 17 00:00:00 2001 From: Jacob Deichert Date: Sun, 13 Oct 2024 12:34:59 -0700 Subject: [PATCH] Update README --- README.md | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 29148c3..2ae0a7b 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ mask test ### Positional arguments -These are defined beside the command name within `(round_brackets)`. They are required arguments that must be supplied for the command to run. [Optional args][2] are coming soon. The argument name is injected into the script's scope as an environment variable. +These are defined beside the command name within `(round_brackets)`. They are required arguments that must be supplied for the command to run. The argument name is injected into the script's scope as an environment variable. **Example:** @@ -105,6 +105,24 @@ echo "Testing $test_case in $file" ~~~ ``` +Optional arguments are defined within `[square_brackets]`. + +**Example:** + +```markdown +## test [test_file] + +> Run tests + +~~~bash +if [[ -n "$test_file" ]]; then + echo "Run tests in $test_file..." +else + echo "Running all tests...." +fi +~~~ +``` + ### Named flags You can define a list of named flags for your commands. The flag name is injected into the script's scope as an environment variable. @@ -154,25 +172,22 @@ echo "Total: $(($price * $TAX))" ~~~ ``` -Coming in v0.11.5: If you add a `choices` list, `mask` will validate if the flag value is one of them. +If you add a `choices` list, `mask` will validate if the flag value is one of them. **Example:** ```markdown -## print (text) - -> Print text with color +## color **OPTIONS** * color * flags: -c --color * type: string * choices: RED, BLUE, GREEN - * desc: Color of the text. -~~~sh -COLOR=${color:RED} # Fallback to RED if not supplied -echo "$COLOR: $text" +~~~bash +COLOR=${color:-RED} # Fallback to RED if not supplied +echo "Color selected = '$COLOR'" ~~~ ```