Skip to content

Commit

Permalink
🐛 fix examples documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaillon committed Jul 1, 2024
1 parent 43ead03 commit 3fc810d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Latest Release](https://img.shields.io/github/v/release/jcaillon/valet?sort=date&style=flat&logo=github&logoColor=white&label=Latest%20release&color=%2350C878)][latest-release]
[![Total downloads](https://img.shields.io/github/downloads/jcaillon/valet/total.svg?style=flat)][releases]
[![MIT license](https://img.shields.io/badge/License-MIT-74A5C2.svg?style=flat)][license]
[![bash 5.1+ required](https://img.shields.io/badge/Requires-bash%20v5.1+-865FC5.svg?logo=gnubash&logoColor=white)][bash]
[![bash 5+ required](https://img.shields.io/badge/Requires-bash%20v5+-865FC5.svg?logo=gnubash&logoColor=white)][bash]

[![icon](docs/static/logo.png)][valet-site]

Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/002.installation/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ url: /docs/installation

## 📦 Dependencies

- Bash version 5.1 or superior is required (might work with older versions but it is not guaranteed).
- Bash version 5 or superior is required (might work with older versions but it is not guaranteed).
- From [GNU coreutils][gnu-core-utils]: it uses `rm`, `mv`, `mkdir` for all commands. It uses `chmod`, `ln` for the installation/updates. *You most likely already have all of these!*
- [curl][curl] and [tar][tar] are needed only if you want to use the self-update command.

Expand Down
4 changes: 3 additions & 1 deletion docs/content/docs/025.command-properties/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ Examples are used in the command help/usage and let the user quickly understand

### ✔️ name

The command for this example. You should not include `valet` as it will be preprended automatically.
The command for this example.

You should not include `valet` as it will be prepended automatically. If you do not want to prepend it, start the name with `!` (useful to illustrate a more complex command line).

| Mandatory? | Default value? |
|----------|---------------|
Expand Down
13 changes: 13 additions & 0 deletions tests.d/1005-lib-io/results.approved.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ Exit code: `0`
3
```

### Testing io::isDirectoryWritable

Exit code: `0`

**Standard** output:

```plaintext
→ io::isDirectoryWritable '/tmp'
Writable
→ io::isDirectoryWritable '/notexisting'
Not writable
```

## Test script 01.invoke

### Testing io::invoke5, should return 1, input stream from string
Expand Down
13 changes: 12 additions & 1 deletion valet.d/commands.d/self-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,19 @@ function declareFinalCommandDefinitionHelpVariables() {
fi
done

# for each example, prepend valet to the example name
local example
local -a examples=()
for example in "${TEMP_CMD_BUILD_examples_name[@]}"; do
if [[ ${example} == "!"* ]]; then
examples+=("${example:1}")
else
examples+=("valet ${example}")
fi
done

# declare examples, arguments and options for the help
if [[ "${#TEMP_CMD_BUILD_examples_name[@]}" -gt 0 ]]; then eval "CMD_EXAMPLES_NAME_${function}=(\"\${TEMP_CMD_BUILD_examples_name[@]}\")"; fi
if [[ "${#examples[@]}" -gt 0 ]]; then eval "CMD_EXAMPLES_NAME_${function}=(\"\${examples[@]}\")"; fi
if [[ "${#TEMP_CMD_BUILD_examples_description[@]}" -gt 0 ]]; then eval "CMD_EXAMPLES_DESCRIPTION_${function}=(\"\${TEMP_CMD_BUILD_examples_description[@]}\")"; fi
eval "CMD_OPTIONS_NAME_${function}=(\"\${TEMP_CMD_BUILD_options_name[@]}\")"
eval "CMD_OPTIONS_DESCRIPTION_${function}=(\"\${TEMP_CMD_BUILD_options_description[@]}\")"
Expand Down
4 changes: 2 additions & 2 deletions valet.d/lib-interactive
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ function interactive::promptYesNoRaw() {
$'\n' | ' ')
break
;;
y)
y | Y)
state=true
break
;;
n)
n | N)
state=false
break
;;
Expand Down
2 changes: 1 addition & 1 deletion valet.d/main
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ function main::getHelpText() {
local examples
if [[ -n "${functionExamples:-}" ]]; then
examples="${cTitle}EXAMPLES${cDefault}"$'\n'$'\n'
mainWriteAsTable "${helpWidth}" "" "CMD_EXAMPLES" "${functionName}"
mainWriteAsTable "${helpWidth}" "${cCommand}" "CMD_EXAMPLES" "${functionName}"
examples+="${RETURNED_VALUE}"$'\n'
fi

Expand Down

0 comments on commit 3fc810d

Please sign in to comment.