๐ฆ Libraries
๐ฆ Libraries
๐งฉ Source libraries from your command function
Useful function are accessible by including a Valet library in your script or command function. For this, you need to source the library that you need, e.g.:
source string
source interactive
All Valet functions are prefixed with the library name. E.g. the function string::cutField
is from the string
library. A clear error message will be output if you are trying to use a library function without sourcing the library.
๐ก
The bash built-in
source
is overridden by a function in Valet. This allows to not source the same file twice, so you can safely call source mylibrary
several times without impacting the runtime performance. If you need to use the default source keyword, use builtin source
.๐ช Use Valet functions directly in bash
Thanks to the self export
command, you can export Valet functions so they are usable directly in your bash session:
eval "$(valet self export -a)"
log::info "Cool logs!"
if interactive::promptYesNo "Do you want to continue?"; then echo "Yes."; else echo "No."; fi
๐ Available libraries
For more details, please check the documentation on each library:
ansi-code
This library exports variables containing ASCII escape codes, enabling interactive programs.
arrayFunctions to manipulate bash arrays.
coreThe core functions of Valet.
fsfsFunctions to display a full screen fuzzy search, which is used for the Valet menus.
interactiveFunctions to make your program interactive.
ioFunctions for file manipulation, command execution…
kurlWrapper functions around curl.
logLogging functions.
profilerFunctions enable and disable the bash profiler.
stringFunctions for string manipulation.
systemFunctions to get system/user information.
testFunctions usable in your test scripts.