diff --git a/docs/static/config.md b/docs/static/config.md index 4bd91c1..574e9cf 100644 --- a/docs/static/config.md +++ b/docs/static/config.md @@ -198,18 +198,18 @@ VALET_CONFIG_COLOR_ACTIVE_BUTTON="${VALET_CONFIG_COLOR_ACTIVE_BUTTON:-}" VALET_CONFIG_COLOR_UNACTIVE_BUTTON="${VALET_CONFIG_COLOR_UNACTIVE_BUTTON:-}" # Colors for fsfs -VALET_COLOR_FSFS_RESET_TEXT="${VALET_COLOR_FSFS_RESET_TEXT:-}" -VALET_COLOR_FSFS_STATIC="${VALET_COLOR_FSFS_STATIC:-}" -VALET_COLOR_FSFS_FOCUS="${VALET_COLOR_FSFS_FOCUS:-}" -VALET_COLOR_FSFS_FOCUS_RESET="${VALET_COLOR_FSFS_FOCUS_RESET:-}" -VALET_COLOR_FSFS_LETTER_HIGHLIGHT="${VALET_COLOR_FSFS_LETTER_HIGHLIGHT:-}" -VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET="${VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET:-}" -VALET_COLOR_FSFS_SELECTED_ITEM="${VALET_COLOR_FSFS_SELECTED_ITEM:-}" -VALET_COLOR_FSFS_SELECTED_ITEM_RESET="${VALET_COLOR_FSFS_SELECTED_ITEM_RESET:-}" -VALET_COLOR_FSFS_PROMPT_STRING="${VALET_COLOR_FSFS_PROMPT_STRING:-}" -VALET_COLOR_FSFS_PROMPT_STRING_RESET="${VALET_COLOR_FSFS_PROMPT_STRING_RESET:-}" -VALET_COLOR_FSFS_COUNT="${VALET_COLOR_FSFS_COUNT:-}" -VALET_COLOR_FSFS_COUNT_RESET="${VALET_COLOR_FSFS_COUNT_RESET:-}" +VALET_CONFIG_FSFS_RESET_TEXT="${VALET_CONFIG_FSFS_RESET_TEXT:-}" +VALET_CONFIG_FSFS_STATIC="${VALET_CONFIG_FSFS_STATIC:-}" +VALET_CONFIG_FSFS_FOCUS="${VALET_CONFIG_FSFS_FOCUS:-}" +VALET_CONFIG_FSFS_FOCUS_RESET="${VALET_CONFIG_FSFS_FOCUS_RESET:-}" +VALET_CONFIG_FSFS_LETTER_HIGHLIGHT="${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT:-}" +VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET="${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET:-}" +VALET_CONFIG_FSFS_SELECTED_ITEM="${VALET_CONFIG_FSFS_SELECTED_ITEM:-}" +VALET_CONFIG_FSFS_SELECTED_ITEM_RESET="${VALET_CONFIG_FSFS_SELECTED_ITEM_RESET:-}" +VALET_CONFIG_FSFS_PROMPT_STRING="${VALET_CONFIG_FSFS_PROMPT_STRING:-}" +VALET_CONFIG_FSFS_PROMPT_STRING_RESET="${VALET_CONFIG_FSFS_PROMPT_STRING_RESET:-}" +VALET_CONFIG_FSFS_COUNT="${VALET_CONFIG_FSFS_COUNT:-}" +VALET_CONFIG_FSFS_COUNT_RESET="${VALET_CONFIG_FSFS_COUNT_RESET:-}" # ----------- # Other configs. diff --git a/examples.d/showcase/showcase-interactive.sh b/examples.d/showcase/showcase-interactive.sh index a7f1490..0fb05a4 100644 --- a/examples.d/showcase/showcase-interactive.sh +++ b/examples.d/showcase/showcase-interactive.sh @@ -63,6 +63,20 @@ function showcaseInteractive() { fsfs::itemSelector "What's your favorite color?" SELECTION_ARRAY "getColorSample" "Color sample" log::info "You selected: ⌜${RETURNED_VALUE}⌝ (index: ⌜${RETURNED_VALUE2}⌝)" + + log::info "Now displaying a spinner" + + interactive::startSpinner + + IDX=0 + while [[ ${IDX} -lt 5 ]]; do + IDX=$((IDX + 1)) + log::info "We can still output logs while the spinner runs..." + sleep 1 + done + + interactive::stopSpinner + log::info "End of demo!" diff --git a/tests.d/1005-lib-io/00.tests.sh b/tests.d/1005-lib-io/00.tests.sh index 4268f27..3cac109 100644 --- a/tests.d/1005-lib-io/00.tests.sh +++ b/tests.d/1005-lib-io/00.tests.sh @@ -8,6 +8,14 @@ function testIo::toAbsolutePath() { echo "→ io::toAbsolutePath \${PWD}/01.invoke.sh" io::toAbsolutePath "${PWD}/01.invoke.sh" && echo "${RETURNED_VALUE}" + echo + echo "→ io::toAbsolutePath ." + io::toAbsolutePath . && echo "${RETURNED_VALUE}" + + echo + echo "→ io::toAbsolutePath .." + io::toAbsolutePath .. && echo "${RETURNED_VALUE}" + echo echo "→ io::toAbsolutePath 01.invoke.sh" io::toAbsolutePath 01.invoke.sh && echo "${RETURNED_VALUE}" diff --git a/tests.d/1005-lib-io/results.approved.md b/tests.d/1005-lib-io/results.approved.md index 4d269d8..5b11d81 100644 --- a/tests.d/1005-lib-io/results.approved.md +++ b/tests.d/1005-lib-io/results.approved.md @@ -12,6 +12,12 @@ Exit code: `0` → io::toAbsolutePath ${PWD}/01.invoke.sh $GLOBAL_VALET_HOME/tests.d/1005-lib-io/01.invoke.sh +→ io::toAbsolutePath . +$GLOBAL_VALET_HOME/tests.d/1005-lib-io + +→ io::toAbsolutePath .. +$GLOBAL_VALET_HOME/tests.d + → io::toAbsolutePath 01.invoke.sh $GLOBAL_VALET_HOME/tests.d/1005-lib-io/01.invoke.sh diff --git a/tests.d/1100-self-config/results.approved.md b/tests.d/1100-self-config/results.approved.md index 8274d4a..2c51e1f 100644 --- a/tests.d/1100-self-config/results.approved.md +++ b/tests.d/1100-self-config/results.approved.md @@ -29,9 +29,10 @@ cat ${configFile} # If you break this file, valet will fail to start. # You can delete it and run the 'valet self config' command to recreate it. -# ----------- -# Custom startup script -# ----------- +## ----------- +## Custom startup script +## ----------- + # You can define a custom startup script that will be sourced by Valet on startup.* # This allows you to define custom functions or variables that will be available in Valet. # For example, it is convenient to translate CI_* variables to VALET_* variables. @@ -49,9 +50,10 @@ if [[ -f "${_CONFIG_DIR}/startup" ]]; then source "${_CONFIG_DIR}/startup" fi -# ----------- -# General config -# ----------- +## ----------- +## General config +## ----------- + # The path to this Valet config file: MUST BE declared outside this file! # Default to the 'config' file in your config directory. # VALET_CONFIG_FILE @@ -106,9 +108,10 @@ VALET_CONFIG_TEST_DIFF_COMMAND="${VALET_CONFIG_TEST_DIFF_COMMAND:-}" # you typed is the exact command that will be executed. VALET_CONFIG_STRICT_MATCHING="${VALET_CONFIG_STRICT_MATCHING:-}" -# ----------- -# Log/output configuration -# ----------- +## ----------- +## Log/output configuration +## ----------- + # If true, will enable the icons (using nerd font). VALET_CONFIG_ENABLE_NERDFONT_ICONS="${VALET_CONFIG_ENABLE_NERDFONT_ICONS:-}" @@ -147,9 +150,10 @@ VALET_CONFIG_LOG_FILENAME_PATTERN="${VALET_CONFIG_LOG_FILENAME_PATTERN:-}" # you can force to use bash by setting this property to true. VALET_CONFIG_LOG_CLEANUP_USING_BASH="${VALET_CONFIG_LOG_CLEANUP_USING_BASH:-}" -# ----------- -# Log icons configuration -# ----------- +## ----------- +## Log icons configuration +## ----------- + # The icon to use for the logs. VALET_CONFIG_ICON_ERROR="${VALET_CONFIG_ICON_ERROR:-}" VALET_CONFIG_ICON_WARNING="${VALET_CONFIG_ICON_WARNING:-}" @@ -162,9 +166,10 @@ VALET_CONFIG_ICON_EXIT="${VALET_CONFIG_ICON_EXIT:-}" VALET_CONFIG_ICON_STOPPED="${VALET_CONFIG_ICON_STOPPED:-}" VALET_CONFIG_ICON_KILLED="${VALET_CONFIG_ICON_KILLED:-}" -# ----------- -# Profiler configuration -# ----------- +## ----------- +## Profiler configuration +## ----------- + # The path to the file in which to write the profiling information for the command. # Defaults to the ~/valet-profiler-{PID}-command.txt file. VALET_CONFIG_COMMAND_PROFILING_FILE="${VALET_CONFIG_COMMAND_PROFILING_FILE:-}" @@ -182,9 +187,10 @@ VALET_CONFIG_STARTUP_PROFILING="${VALET_CONFIG_STARTUP_PROFILING:-}" # Defaults to the ~/valet-profiler-{PID}.txt file. VALET_CONFIG_STARTUP_PROFILING_FILE="${VALET_CONFIG_STARTUP_PROFILING_FILE:-}" -# ----------- -# Colors to use in Valet. -# ----------- +## ----------- +## Colors to use in Valet. +## ----------- + # You should define a color using an ANSI escape sequence. # See https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797. # E.g., this will set the INFO levels logs to blue: @@ -212,22 +218,42 @@ VALET_CONFIG_COLOR_ACTIVE_BUTTON="${VALET_CONFIG_COLOR_ACTIVE_BUTTON:-}" VALET_CONFIG_COLOR_UNACTIVE_BUTTON="${VALET_CONFIG_COLOR_UNACTIVE_BUTTON:-}" # Colors for fsfs -VALET_COLOR_FSFS_RESET_TEXT="${VALET_COLOR_FSFS_RESET_TEXT:-}" -VALET_COLOR_FSFS_STATIC="${VALET_COLOR_FSFS_STATIC:-}" -VALET_COLOR_FSFS_FOCUS="${VALET_COLOR_FSFS_FOCUS:-}" -VALET_COLOR_FSFS_FOCUS_RESET="${VALET_COLOR_FSFS_FOCUS_RESET:-}" -VALET_COLOR_FSFS_LETTER_HIGHLIGHT="${VALET_COLOR_FSFS_LETTER_HIGHLIGHT:-}" -VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET="${VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET:-}" -VALET_COLOR_FSFS_SELECTED_ITEM="${VALET_COLOR_FSFS_SELECTED_ITEM:-}" -VALET_COLOR_FSFS_SELECTED_ITEM_RESET="${VALET_COLOR_FSFS_SELECTED_ITEM_RESET:-}" -VALET_COLOR_FSFS_PROMPT_STRING="${VALET_COLOR_FSFS_PROMPT_STRING:-}" -VALET_COLOR_FSFS_PROMPT_STRING_RESET="${VALET_COLOR_FSFS_PROMPT_STRING_RESET:-}" -VALET_COLOR_FSFS_COUNT="${VALET_COLOR_FSFS_COUNT:-}" -VALET_COLOR_FSFS_COUNT_RESET="${VALET_COLOR_FSFS_COUNT_RESET:-}" - -# ----------- -# Other configs. -# ----------- +VALET_CONFIG_FSFS_RESET_TEXT="${VALET_CONFIG_FSFS_RESET_TEXT:-}" +VALET_CONFIG_FSFS_STATIC="${VALET_CONFIG_FSFS_STATIC:-}" +VALET_CONFIG_FSFS_FOCUS="${VALET_CONFIG_FSFS_FOCUS:-}" +VALET_CONFIG_FSFS_FOCUS_RESET="${VALET_CONFIG_FSFS_FOCUS_RESET:-}" +VALET_CONFIG_FSFS_LETTER_HIGHLIGHT="${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT:-}" +VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET="${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET:-}" +VALET_CONFIG_FSFS_SELECTED_ITEM="${VALET_CONFIG_FSFS_SELECTED_ITEM:-}" +VALET_CONFIG_FSFS_SELECTED_ITEM_RESET="${VALET_CONFIG_FSFS_SELECTED_ITEM_RESET:-}" +VALET_CONFIG_FSFS_PROMPT_STRING="${VALET_CONFIG_FSFS_PROMPT_STRING:-}" +VALET_CONFIG_FSFS_PROMPT_STRING_RESET="${VALET_CONFIG_FSFS_PROMPT_STRING_RESET:-}" +VALET_CONFIG_FSFS_COUNT="${VALET_CONFIG_FSFS_COUNT:-}" +VALET_CONFIG_FSFS_COUNT_RESET="${VALET_CONFIG_FSFS_COUNT_RESET:-}" + +## ----------- +## Interactive mode configuration. +## ----------- + +# Change the default time between 2 frames for a spinner (in seconds, can be a float number). +VALET_CONFIG_SPINNER_DELAY="${VALET_CONFIG_SPINNER_DELAY:-}" + +# Change the default spinner characters (one character represents one frame of the animation). +# Examples: +# +# - ◐◓◑◒ +# - ▖▘▝▗ +# - ⣾⣽⣻⢿⡿⣟⣯⣷ +# - ⢄⢂⢁⡁⡈⡐⡠ +# - ◡⊙◠ +# - ▌▀▐▄ +# - ⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆ +VALET_CONFIG_SPINNER_CHARACTERS="${VALET_CONFIG_SPINNER_CHARACTERS:-}" + + +## ----------- +## Other configs. +## ----------- # If true, will enable the automatic bump of the version of Valet on build. # Intended for Valet developers only. @@ -304,9 +330,10 @@ cat ${configFile} # If you break this file, valet will fail to start. # You can delete it and run the 'valet self config' command to recreate it. -# ----------- -# Custom startup script -# ----------- +## ----------- +## Custom startup script +## ----------- + # You can define a custom startup script that will be sourced by Valet on startup.* # This allows you to define custom functions or variables that will be available in Valet. # For example, it is convenient to translate CI_* variables to VALET_* variables. @@ -324,9 +351,10 @@ if [[ -f "${_CONFIG_DIR}/startup" ]]; then source "${_CONFIG_DIR}/startup" fi -# ----------- -# General config -# ----------- +## ----------- +## General config +## ----------- + # The path to this Valet config file: MUST BE declared outside this file! # Default to the 'config' file in your config directory. # VALET_CONFIG_FILE @@ -381,9 +409,10 @@ VALET_CONFIG_TEST_DIFF_COMMAND="${VALET_CONFIG_TEST_DIFF_COMMAND:-}" # you typed is the exact command that will be executed. VALET_CONFIG_STRICT_MATCHING="${VALET_CONFIG_STRICT_MATCHING:-}" -# ----------- -# Log/output configuration -# ----------- +## ----------- +## Log/output configuration +## ----------- + # If true, will enable the icons (using nerd font). VALET_CONFIG_ENABLE_NERDFONT_ICONS="${VALET_CONFIG_ENABLE_NERDFONT_ICONS:-}" @@ -422,9 +451,10 @@ VALET_CONFIG_LOG_FILENAME_PATTERN="${VALET_CONFIG_LOG_FILENAME_PATTERN:-}" # you can force to use bash by setting this property to true. VALET_CONFIG_LOG_CLEANUP_USING_BASH="${VALET_CONFIG_LOG_CLEANUP_USING_BASH:-}" -# ----------- -# Log icons configuration -# ----------- +## ----------- +## Log icons configuration +## ----------- + # The icon to use for the logs. VALET_CONFIG_ICON_ERROR="${VALET_CONFIG_ICON_ERROR:-}" VALET_CONFIG_ICON_WARNING="${VALET_CONFIG_ICON_WARNING:-}" @@ -437,9 +467,10 @@ VALET_CONFIG_ICON_EXIT="${VALET_CONFIG_ICON_EXIT:-}" VALET_CONFIG_ICON_STOPPED="${VALET_CONFIG_ICON_STOPPED:-}" VALET_CONFIG_ICON_KILLED="${VALET_CONFIG_ICON_KILLED:-}" -# ----------- -# Profiler configuration -# ----------- +## ----------- +## Profiler configuration +## ----------- + # The path to the file in which to write the profiling information for the command. # Defaults to the ~/valet-profiler-{PID}-command.txt file. VALET_CONFIG_COMMAND_PROFILING_FILE="${VALET_CONFIG_COMMAND_PROFILING_FILE:-}" @@ -457,9 +488,10 @@ VALET_CONFIG_STARTUP_PROFILING="${VALET_CONFIG_STARTUP_PROFILING:-}" # Defaults to the ~/valet-profiler-{PID}.txt file. VALET_CONFIG_STARTUP_PROFILING_FILE="${VALET_CONFIG_STARTUP_PROFILING_FILE:-}" -# ----------- -# Colors to use in Valet. -# ----------- +## ----------- +## Colors to use in Valet. +## ----------- + # You should define a color using an ANSI escape sequence. # See https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797. # E.g., this will set the INFO levels logs to blue: @@ -487,22 +519,42 @@ VALET_CONFIG_COLOR_ACTIVE_BUTTON="${VALET_CONFIG_COLOR_ACTIVE_BUTTON:-}" VALET_CONFIG_COLOR_UNACTIVE_BUTTON="${VALET_CONFIG_COLOR_UNACTIVE_BUTTON:-}" # Colors for fsfs -VALET_COLOR_FSFS_RESET_TEXT="${VALET_COLOR_FSFS_RESET_TEXT:-}" -VALET_COLOR_FSFS_STATIC="${VALET_COLOR_FSFS_STATIC:-}" -VALET_COLOR_FSFS_FOCUS="${VALET_COLOR_FSFS_FOCUS:-}" -VALET_COLOR_FSFS_FOCUS_RESET="${VALET_COLOR_FSFS_FOCUS_RESET:-}" -VALET_COLOR_FSFS_LETTER_HIGHLIGHT="${VALET_COLOR_FSFS_LETTER_HIGHLIGHT:-}" -VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET="${VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET:-}" -VALET_COLOR_FSFS_SELECTED_ITEM="${VALET_COLOR_FSFS_SELECTED_ITEM:-}" -VALET_COLOR_FSFS_SELECTED_ITEM_RESET="${VALET_COLOR_FSFS_SELECTED_ITEM_RESET:-}" -VALET_COLOR_FSFS_PROMPT_STRING="${VALET_COLOR_FSFS_PROMPT_STRING:-}" -VALET_COLOR_FSFS_PROMPT_STRING_RESET="${VALET_COLOR_FSFS_PROMPT_STRING_RESET:-}" -VALET_COLOR_FSFS_COUNT="${VALET_COLOR_FSFS_COUNT:-}" -VALET_COLOR_FSFS_COUNT_RESET="${VALET_COLOR_FSFS_COUNT_RESET:-}" - -# ----------- -# Other configs. -# ----------- +VALET_CONFIG_FSFS_RESET_TEXT="${VALET_CONFIG_FSFS_RESET_TEXT:-}" +VALET_CONFIG_FSFS_STATIC="${VALET_CONFIG_FSFS_STATIC:-}" +VALET_CONFIG_FSFS_FOCUS="${VALET_CONFIG_FSFS_FOCUS:-}" +VALET_CONFIG_FSFS_FOCUS_RESET="${VALET_CONFIG_FSFS_FOCUS_RESET:-}" +VALET_CONFIG_FSFS_LETTER_HIGHLIGHT="${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT:-}" +VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET="${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET:-}" +VALET_CONFIG_FSFS_SELECTED_ITEM="${VALET_CONFIG_FSFS_SELECTED_ITEM:-}" +VALET_CONFIG_FSFS_SELECTED_ITEM_RESET="${VALET_CONFIG_FSFS_SELECTED_ITEM_RESET:-}" +VALET_CONFIG_FSFS_PROMPT_STRING="${VALET_CONFIG_FSFS_PROMPT_STRING:-}" +VALET_CONFIG_FSFS_PROMPT_STRING_RESET="${VALET_CONFIG_FSFS_PROMPT_STRING_RESET:-}" +VALET_CONFIG_FSFS_COUNT="${VALET_CONFIG_FSFS_COUNT:-}" +VALET_CONFIG_FSFS_COUNT_RESET="${VALET_CONFIG_FSFS_COUNT_RESET:-}" + +## ----------- +## Interactive mode configuration. +## ----------- + +# Change the default time between 2 frames for a spinner (in seconds, can be a float number). +VALET_CONFIG_SPINNER_DELAY="${VALET_CONFIG_SPINNER_DELAY:-}" + +# Change the default spinner characters (one character represents one frame of the animation). +# Examples: +# +# - ◐◓◑◒ +# - ▖▘▝▗ +# - ⣾⣽⣻⢿⡿⣟⣯⣷ +# - ⢄⢂⢁⡁⡈⡐⡠ +# - ◡⊙◠ +# - ▌▀▐▄ +# - ⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆ +VALET_CONFIG_SPINNER_CHARACTERS="${VALET_CONFIG_SPINNER_CHARACTERS:-}" + + +## ----------- +## Other configs. +## ----------- # If true, will enable the automatic bump of the version of Valet on build. # Intended for Valet developers only. diff --git a/tests.d/1103-self-release/results.approved.md b/tests.d/1103-self-release/results.approved.md index f994ab9..16ac3b8 100644 --- a/tests.d/1103-self-release/results.approved.md +++ b/tests.d/1103-self-release/results.approved.md @@ -18,7 +18,7 @@ Exit code: `0` INFO Dry run mode is enabled, no changes will be made. ▶ called io::invoke git rev-parse HEAD INFO The current version of valet is: 1.2.3. -INFO Found 102 functions with documentation. +INFO Found 104 functions with documentation. ▶ called io::invoke git tag --sort=version:refname --no-color INFO The last tag is: v1.2.3. ▶ called io::invoke git log --pretty=format:%s v1.2.3..HEAD @@ -137,6 +137,8 @@ DEBUG Found function: ⌜interactive::createSpace⌝ DEBUG Found function: ⌜interactive::getCursorPosition⌝ DEBUG Found function: ⌜interactive::switchToFullScreen⌝ DEBUG Found function: ⌜interactive::switchBackFromFullScreen⌝ +DEBUG Found function: ⌜interactive::startSpinner⌝ +DEBUG Found function: ⌜interactive::stopSpinner⌝ DEBUG Found function: ⌜io::toAbsolutePath⌝ DEBUG Found function: ⌜io::invokef5⌝ DEBUG Found function: ⌜io::invokef2⌝ @@ -181,7 +183,7 @@ DEBUG Found function: ⌜system::getNotExistingCommands⌝ DEBUG Found function: ⌜system::commandExists⌝ DEBUG Found function: ⌜test::commentTest⌝ DEBUG Found function: ⌜test::endTest⌝ -INFO Found 102 functions with documentation. +INFO Found 104 functions with documentation. ▶ called io::invoke rm -f $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/array.md ▶ called io::invoke rm -f $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/codes.md ▶ called io::invoke rm -f $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/core.md @@ -382,6 +384,8 @@ INFO Found 102 functions with documentation. ▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/array.md ▶ called io::writeToFileFromRef $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/array.md ▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/array.md +▶ called io::writeToFileFromRef $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/interactive.md +▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/interactive.md ▶ called io::writeToFileFromRef $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/log.md ▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/log.md ▶ called io::writeToFileFromRef $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/io.md @@ -398,6 +402,8 @@ INFO Found 102 functions with documentation. ▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/io.md ▶ called io::writeToFileFromRef $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/io.md ▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/io.md +▶ called io::writeToFileFromRef $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/interactive.md +▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/interactive.md ▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/array.md ▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/codes.md ▶ called io::writeToFile $GLOBAL_VALET_HOME/docs/content/docs/300.libraries/core.md diff --git a/valet.d/commands.d/self-config.sh b/valet.d/commands.d/self-config.sh index b12599a..801030e 100644 --- a/valet.d/commands.d/self-config.sh +++ b/valet.d/commands.d/self-config.sh @@ -116,9 +116,10 @@ function config::getFileContent() { # If you break this file, valet will fail to start. # You can delete it and run the 'valet self config' command to recreate it. -# ----------- -# Custom startup script -# ----------- +## ----------- +## Custom startup script +## ----------- + # You can define a custom startup script that will be sourced by Valet on startup.* # This allows you to define custom functions or variables that will be available in Valet. # For example, it is convenient to translate CI_* variables to VALET_* variables. @@ -136,9 +137,10 @@ if [[ -f \"\${_CONFIG_DIR}/startup\" ]]; then source \"\${_CONFIG_DIR}/startup\" fi -# ----------- -# General config -# ----------- +## ----------- +## General config +## ----------- + # The path to this Valet config file: MUST BE declared outside this file! # Default to the 'config' file in your config directory. # VALET_CONFIG_FILE @@ -193,9 +195,10 @@ VALET_CONFIG_TEST_DIFF_COMMAND=\"\${VALET_CONFIG_TEST_DIFF_COMMAND:-${EXPORTED_V # you typed is the exact command that will be executed. VALET_CONFIG_STRICT_MATCHING=\"\${VALET_CONFIG_STRICT_MATCHING:-${EXPORTED_VALET_CONFIG_STRICT_MATCHING:-}}\" -# ----------- -# Log/output configuration -# ----------- +## ----------- +## Log/output configuration +## ----------- + # If true, will enable the icons (using nerd font). VALET_CONFIG_ENABLE_NERDFONT_ICONS=\"\${VALET_CONFIG_ENABLE_NERDFONT_ICONS:-${EXPORTED_VALET_CONFIG_ENABLE_NERDFONT_ICONS:-}}\" @@ -234,9 +237,10 @@ VALET_CONFIG_LOG_FILENAME_PATTERN=\"\${VALET_CONFIG_LOG_FILENAME_PATTERN:-${EXPO # you can force to use bash by setting this property to true. VALET_CONFIG_LOG_CLEANUP_USING_BASH=\"\${VALET_CONFIG_LOG_CLEANUP_USING_BASH:-${EXPORTED_VALET_CONFIG_LOG_CLEANUP_USING_BASH:-}}\" -# ----------- -# Log icons configuration -# ----------- +## ----------- +## Log icons configuration +## ----------- + # The icon to use for the logs. VALET_CONFIG_ICON_ERROR=\"\${VALET_CONFIG_ICON_ERROR:-${EXPORTED_VALET_CONFIG_ICON_ERROR:-}}\" VALET_CONFIG_ICON_WARNING=\"\${VALET_CONFIG_ICON_WARNING:-${EXPORTED_VALET_CONFIG_ICON_WARNING:-}}\" @@ -249,9 +253,10 @@ VALET_CONFIG_ICON_EXIT=\"\${VALET_CONFIG_ICON_EXIT:-${EXPORTED_VALET_CONFIG_ICON VALET_CONFIG_ICON_STOPPED=\"\${VALET_CONFIG_ICON_STOPPED:-${EXPORTED_VALET_CONFIG_ICON_STOPPED:-}}\" VALET_CONFIG_ICON_KILLED=\"\${VALET_CONFIG_ICON_KILLED:-${EXPORTED_VALET_CONFIG_ICON_KILLED:-}}\" -# ----------- -# Profiler configuration -# ----------- +## ----------- +## Profiler configuration +## ----------- + # The path to the file in which to write the profiling information for the command. # Defaults to the ~/valet-profiler-{PID}-command.txt file. VALET_CONFIG_COMMAND_PROFILING_FILE=\"\${VALET_CONFIG_COMMAND_PROFILING_FILE:-${EXPORTED_VALET_CONFIG_COMMAND_PROFILING_FILE:-}}\" @@ -269,9 +274,10 @@ VALET_CONFIG_STARTUP_PROFILING=\"\${VALET_CONFIG_STARTUP_PROFILING:-${EXPORTED_V # Defaults to the ~/valet-profiler-{PID}.txt file. VALET_CONFIG_STARTUP_PROFILING_FILE=\"\${VALET_CONFIG_STARTUP_PROFILING_FILE:-${EXPORTED_VALET_CONFIG_STARTUP_PROFILING_FILE:-}}\" -# ----------- -# Colors to use in Valet. -# ----------- +## ----------- +## Colors to use in Valet. +## ----------- + # You should define a color using an ANSI escape sequence. # See https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797. # E.g., this will set the INFO levels logs to blue: @@ -299,22 +305,42 @@ VALET_CONFIG_COLOR_ACTIVE_BUTTON=\"\${VALET_CONFIG_COLOR_ACTIVE_BUTTON:-${EXPORT VALET_CONFIG_COLOR_UNACTIVE_BUTTON=\"\${VALET_CONFIG_COLOR_UNACTIVE_BUTTON:-${EXPORTED_VALET_CONFIG_COLOR_UNACTIVE_BUTTON:-}}\" # Colors for fsfs -VALET_COLOR_FSFS_RESET_TEXT=\"\${VALET_COLOR_FSFS_RESET_TEXT:-${EXPORTED_VALET_COLOR_FSFS_RESET_TEXT:-}}\" -VALET_COLOR_FSFS_STATIC=\"\${VALET_COLOR_FSFS_STATIC:-${EXPORTED_VALET_COLOR_FSFS_STATIC:-}}\" -VALET_COLOR_FSFS_FOCUS=\"\${VALET_COLOR_FSFS_FOCUS:-${EXPORTED_VALET_COLOR_FSFS_FOCUS:-}}\" -VALET_COLOR_FSFS_FOCUS_RESET=\"\${VALET_COLOR_FSFS_FOCUS_RESET:-${EXPORTED_VALET_COLOR_FSFS_FOCUS_RESET:-}}\" -VALET_COLOR_FSFS_LETTER_HIGHLIGHT=\"\${VALET_COLOR_FSFS_LETTER_HIGHLIGHT:-${EXPORTED_VALET_COLOR_FSFS_LETTER_HIGHLIGHT:-}}\" -VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET=\"\${VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET:-${EXPORTED_VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET:-}}\" -VALET_COLOR_FSFS_SELECTED_ITEM=\"\${VALET_COLOR_FSFS_SELECTED_ITEM:-${EXPORTED_VALET_COLOR_FSFS_SELECTED_ITEM:-}}\" -VALET_COLOR_FSFS_SELECTED_ITEM_RESET=\"\${VALET_COLOR_FSFS_SELECTED_ITEM_RESET:-${EXPORTED_VALET_COLOR_FSFS_SELECTED_ITEM_RESET:-}}\" -VALET_COLOR_FSFS_PROMPT_STRING=\"\${VALET_COLOR_FSFS_PROMPT_STRING:-${EXPORTED_VALET_COLOR_FSFS_PROMPT_STRING:-}}\" -VALET_COLOR_FSFS_PROMPT_STRING_RESET=\"\${VALET_COLOR_FSFS_PROMPT_STRING_RESET:-${EXPORTED_VALET_COLOR_FSFS_PROMPT_STRING_RESET:-}}\" -VALET_COLOR_FSFS_COUNT=\"\${VALET_COLOR_FSFS_COUNT:-${EXPORTED_VALET_COLOR_FSFS_COUNT:-}}\" -VALET_COLOR_FSFS_COUNT_RESET=\"\${VALET_COLOR_FSFS_COUNT_RESET:-${EXPORTED_VALET_COLOR_FSFS_COUNT_RESET:-}}\" - -# ----------- -# Other configs. -# ----------- +VALET_CONFIG_FSFS_RESET_TEXT=\"\${VALET_CONFIG_FSFS_RESET_TEXT:-${EXPORTED_VALET_CONFIG_FSFS_RESET_TEXT:-}}\" +VALET_CONFIG_FSFS_STATIC=\"\${VALET_CONFIG_FSFS_STATIC:-${EXPORTED_VALET_CONFIG_FSFS_STATIC:-}}\" +VALET_CONFIG_FSFS_FOCUS=\"\${VALET_CONFIG_FSFS_FOCUS:-${EXPORTED_VALET_CONFIG_FSFS_FOCUS:-}}\" +VALET_CONFIG_FSFS_FOCUS_RESET=\"\${VALET_CONFIG_FSFS_FOCUS_RESET:-${EXPORTED_VALET_CONFIG_FSFS_FOCUS_RESET:-}}\" +VALET_CONFIG_FSFS_LETTER_HIGHLIGHT=\"\${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT:-${EXPORTED_VALET_CONFIG_FSFS_LETTER_HIGHLIGHT:-}}\" +VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET=\"\${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET:-${EXPORTED_VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET:-}}\" +VALET_CONFIG_FSFS_SELECTED_ITEM=\"\${VALET_CONFIG_FSFS_SELECTED_ITEM:-${EXPORTED_VALET_CONFIG_FSFS_SELECTED_ITEM:-}}\" +VALET_CONFIG_FSFS_SELECTED_ITEM_RESET=\"\${VALET_CONFIG_FSFS_SELECTED_ITEM_RESET:-${EXPORTED_VALET_CONFIG_FSFS_SELECTED_ITEM_RESET:-}}\" +VALET_CONFIG_FSFS_PROMPT_STRING=\"\${VALET_CONFIG_FSFS_PROMPT_STRING:-${EXPORTED_VALET_CONFIG_FSFS_PROMPT_STRING:-}}\" +VALET_CONFIG_FSFS_PROMPT_STRING_RESET=\"\${VALET_CONFIG_FSFS_PROMPT_STRING_RESET:-${EXPORTED_VALET_CONFIG_FSFS_PROMPT_STRING_RESET:-}}\" +VALET_CONFIG_FSFS_COUNT=\"\${VALET_CONFIG_FSFS_COUNT:-${EXPORTED_VALET_CONFIG_FSFS_COUNT:-}}\" +VALET_CONFIG_FSFS_COUNT_RESET=\"\${VALET_CONFIG_FSFS_COUNT_RESET:-${EXPORTED_VALET_CONFIG_FSFS_COUNT_RESET:-}}\" + +## ----------- +## Interactive mode configuration. +## ----------- + +# Change the default time between 2 frames for a spinner (in seconds, can be a float number). +VALET_CONFIG_SPINNER_DELAY=\"\${VALET_CONFIG_SPINNER_DELAY:-${EXPORTED_VALET_CONFIG_SPINNER_DELAY:-}}\" + +# Change the default spinner characters (one character represents one frame of the animation). +# Examples: +# +# - ◐◓◑◒ +# - ▖▘▝▗ +# - ⣾⣽⣻⢿⡿⣟⣯⣷ +# - ⢄⢂⢁⡁⡈⡐⡠ +# - ◡⊙◠ +# - ▌▀▐▄ +# - ⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆ +VALET_CONFIG_SPINNER_CHARACTERS=\"\${VALET_CONFIG_SPINNER_CHARACTERS:-${EXPORTED_VALET_CONFIG_SPINNER_CHARACTERS:-}}\" + + +## ----------- +## Other configs. +## ----------- # If true, will enable the automatic bump of the version of Valet on build. # Intended for Valet developers only. diff --git a/valet.d/lib-fsfs b/valet.d/lib-fsfs index 0aeaa1a..04b9af5 100644 --- a/valet.d/lib-fsfs +++ b/valet.d/lib-fsfs @@ -165,18 +165,18 @@ function fsfsInitialize() { # set up colors if [[ ${VALET_CONFIG_ENABLE_COLORS:-} == "true" ]]; then - FSFS_COLOR_RESET_TEXT="${VALET_COLOR_FSFS_RESET_TEXT:-"${AC__TEXT_RESET}"}" - FSFS_COLOR_STATIC="${VALET_COLOR_FSFS_STATIC:-"${AC__FG_BRIGHT_BLACK}"}" - FSFS_COLOR_FOCUS="${VALET_COLOR_FSFS_FOCUS:-"${AC__FG_MAGENTA}"}" - FSFS_COLOR_FOCUS_RESET="${VALET_COLOR_FSFS_FOCUS_RESET:-"${AC__FG_RESET}"}" - FSFS_COLOR_LETTER_HIGHLIGHT="${VALET_COLOR_FSFS_LETTER_HIGHLIGHT:-"${AC__TEXT_INVERSE}${AC__FG_MAGENTA}"}" - FSFS_COLOR_LETTER_HIGHLIGHT_RESET="${VALET_COLOR_FSFS_LETTER_HIGHLIGHT_RESET:-"${AC__TEXT_NO_INVERSE}${AC__FG_RESET}"}" - FSFS_COLOR_SELECTED_ITEM="${VALET_COLOR_FSFS_SELECTED_ITEM:-"${AC__BG_BLACK}"}" - FSFS_COLOR_SELECTED_ITEM_RESET="${VALET_COLOR_FSFS_SELECTED_ITEM_RESET:-"${AC__BG_RESET}"}" - FSFS_COLOR_PROMPT_STRING="${VALET_COLOR_FSFS_PROMPT_STRING:-"${AC__FG_CYAN}${AC__TEXT_BOLD}"}" - FSFS_COLOR_PROMPT_STRING_RESET="${VALET_COLOR_FSFS_PROMPT_STRING_RESET:-"${AC__TEXT_RESET}"}" - FSFS_COLOR_COUNT="${VALET_COLOR_FSFS_COUNT:-"${AC__FG_YELLOW}"}" - FSFS_COLOR_COUNT_RESET="${VALET_COLOR_FSFS_COUNT_RESET:-"${AC__TEXT_RESET}"}" + FSFS_COLOR_RESET_TEXT="${VALET_CONFIG_FSFS_RESET_TEXT:-"${AC__TEXT_RESET}"}" + FSFS_COLOR_STATIC="${VALET_CONFIG_FSFS_STATIC:-"${AC__FG_BRIGHT_BLACK}"}" + FSFS_COLOR_FOCUS="${VALET_CONFIG_FSFS_FOCUS:-"${AC__FG_MAGENTA}"}" + FSFS_COLOR_FOCUS_RESET="${VALET_CONFIG_FSFS_FOCUS_RESET:-"${AC__FG_RESET}"}" + FSFS_COLOR_LETTER_HIGHLIGHT="${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT:-"${AC__TEXT_INVERSE}${AC__FG_MAGENTA}"}" + FSFS_COLOR_LETTER_HIGHLIGHT_RESET="${VALET_CONFIG_FSFS_LETTER_HIGHLIGHT_RESET:-"${AC__TEXT_NO_INVERSE}${AC__FG_RESET}"}" + FSFS_COLOR_SELECTED_ITEM="${VALET_CONFIG_FSFS_SELECTED_ITEM:-"${AC__BG_BLACK}"}" + FSFS_COLOR_SELECTED_ITEM_RESET="${VALET_CONFIG_FSFS_SELECTED_ITEM_RESET:-"${AC__BG_RESET}"}" + FSFS_COLOR_PROMPT_STRING="${VALET_CONFIG_FSFS_PROMPT_STRING:-"${AC__FG_CYAN}${AC__TEXT_BOLD}"}" + FSFS_COLOR_PROMPT_STRING_RESET="${VALET_CONFIG_FSFS_PROMPT_STRING_RESET:-"${AC__TEXT_RESET}"}" + FSFS_COLOR_COUNT="${VALET_CONFIG_FSFS_COUNT:-"${AC__FG_YELLOW}"}" + FSFS_COLOR_COUNT_RESET="${VALET_CONFIG_FSFS_COUNT_RESET:-"${AC__TEXT_RESET}"}" else FSFS_COLOR_RESET_TEXT="" FSFS_COLOR_STATIC="" diff --git a/valet.d/lib-interactive b/valet.d/lib-interactive index 9bf24ea..2ff80bb 100644 --- a/valet.d/lib-interactive +++ b/valet.d/lib-interactive @@ -484,9 +484,9 @@ function interactive::createSpace() { # interactive::getCursorPosition # ``` function interactive::getCursorPosition() { - local escapeCode IFS + local _escapeCode IFS # we request the position and first read \e[ - IFS='' read -d '' -p "${AC__REQUEST_CURSOR_POSITION}" -n 2 -sr escapeCode || : + IFS='' read -d '' -p "${AC__REQUEST_CURSOR_POSITION}" -n 2 -sr _escapeCode || : # then read line;colR IFS=';' read -d 'R' -sr CURSOR_LINE CURSOR_COLUMN || : } @@ -552,4 +552,70 @@ function interactive::switchBackFromFullScreen() { io::readFile "${FSFS_TEMPORARY_ERROR_FILE}" log::error "Error messages during the interactive session:"$'\n'"${RETURNED_VALUE%$'\n'}" fi +} + +#=============================================================== +# >>> Wait spinner +#=============================================================== + +function interactiveStartBackgroundSpinner() { + local frameDelay="${1:-${VALET_CONFIG_SPINNER_DELAY:-0.1}}" + local maxFrames="${2:-${VALET_CONFIG_SPINNER_MAX_FRAMES:-9223372036854775807}}" + local spinner="${3:-${VALET_CONFIG_SPINNER_CHARACTERS:-"⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"}}" + + # shellcheck source=lib-io + source io + + # Hide the cursor + printf "%s" $'\e[?25l' + + local -i spinnerIndex=0 + local -i loop=0 + while [[ ${loop} -lt ${maxFrames} ]]; do + printf '%s%s' "${spinner:${spinnerIndex}:1}" $'\b' 1>&2 + spinnerIndex=$((spinnerIndex >= ${#spinner} - 1 ? 0 : spinnerIndex + 1)) + loop+=1 + io::sleep "${frameDelay}" + done +} + +# ## interactive::startSpinner +# +# Starts a wait spinner animation that will be displayed until interactive::stopSpinner is called. +# +# Outputs to stderr. +# Contrary to interactive::startSpinner, this spinner will run in the background and will not block the main thread. +# The main thread can continue to output logs while this spinner is running. +# +# - $1: frame delay _as float_: +# the time in seconds between each frame of the spinner +# (defaults to VALET_CONFIG_SPINNER_DELAY=0.1) +# - $2: max frames _as int_: +# the maximum number of frames to display +# (defaults to 9223372036854775807) +# - $3: spinner _as string_: +# the spinner to display (each character is a frame) +# (defaults to VALET_CONFIG_SPINNER_CHARACTERS="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏") +# +# ```bash +# interactive::startSpinner 0.05 999 "⢄⢂⢁⡁⡈⡐⡠" +# ``` +function interactive::startSpinner() { + coproc { interactiveStartBackgroundSpinner "$@"; } 1>&2 + _SPINNER_PID="${COPROC_PID:-${NAME_PID:-}}" +} + +# ## interactive::stopSpinner +# +# Stops the wait spinner animation started by interactive::startSpinner. +# +# ```bash +# interactive::stopSpinner +# ``` +function interactive::stopSpinner() { + if [[ -n "${_SPINNER_PID}" ]]; then + kill "${_SPINNER_PID}" 1>/dev/null || : + fi + # Show the cursor + printf "%s" $'\e[?25h' } \ No newline at end of file diff --git a/valet.d/lib-io b/valet.d/lib-io index 83cb2d0..6cf885e 100644 --- a/valet.d/lib-io +++ b/valet.d/lib-io @@ -29,6 +29,15 @@ function io::toAbsolutePath() { return 0 fi + # if the file is relative path starting with . + if [[ ${file} == "." ]]; then + RETURNED_VALUE="${PWD}" + return 0 + elif [[ ${file} == ".." ]]; then + RETURNED_VALUE="${PWD%/*}" + return 0 + fi + # if the file is a relative path (not containing ..), we return the absolute path RETURNED_VALUE="${PWD}/${file#./}" if [[ ${file} != *".."* && -e "${RETURNED_VALUE}" ]]; then @@ -42,9 +51,7 @@ function io::toAbsolutePath() { return 0 fi - # other cases of relative paths not handled: - # - file directory does not exist - # - the path is .. or . + # other cases of relative paths not handled. RETURNED_VALUE="${PWD}/${file#./}" } diff --git a/valet.d/main b/valet.d/main index 44ef3c8..4bab2e9 100644 --- a/valet.d/main +++ b/valet.d/main @@ -34,6 +34,11 @@ function main::onExitInternal() { # disable the profiler if still on if [[ ${_ACTIVE_PROFILER:-} == "1" ]]; then profiler::disable; fi + # kill spinner if still running + if [[ -n ${_SPINNER_PID:-} ]]; then + kill -9 "${_SPINNER_PID}" &>/dev/null + fi + log::debug "Exiting with code ${rc} after ${SECONDS}s." if command -v onExitTest 1>/dev/null 2>&1; then # this is for the self test command, we need to inform the user in case of an diff --git a/valet.d/version b/valet.d/version index 3428dd4..1aab9a4 100644 --- a/valet.d/version +++ b/valet.d/version @@ -1 +1 @@ -0.20.3 \ No newline at end of file +0.20.16 \ No newline at end of file