| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Cache stdout of any process.
Notice how it outputs the same date. It's using the cache.
mache date
sleep 2
mache dateza 25 mrt 2023 19:25:50 CET za 25 mrt 2023 19:25:50 CET
If we supply different options it will create a new cache.
mache 'date -d "1 Apr 2020"'
mache 'date -d "2 Apr 2020"'wo 1 apr 2020 0:00:00 CEST do 2 apr 2020 0:00:00 CEST
You can also provide a script with arguments. This does not require one to quote the complete command.
mache /bin/echo hello
mache /bin/echo hello worldhello hello world
Notice that it recomputes the cache for both commands separately. This is because the options are not equal.
Use printf style formatting.
mache 'echo "%s"' hello world
mache 'echo "%s"' 'hello world'hello world hello world
You can also make a mache script. These scripts will cache by default. Simply define the following shebang at the top of that script.
cat ./t/date#!/usr/bin/env mache #!/usr/bin/env bash date "$@"
We can now run that script assuming you made it executable. (chmod +x ./t/date)
./t/datevr 24 mei 2024 14:13:28 CEST
By default mache will use the cache if present. You can remake the cache:
./t/date
sleep 2
REMACHE=1 ./t/datevr 24 mei 2024 14:13:28 CEST vr 24 mei 2024 14:13:38 CEST
A mache script does not cache when the script exits with non zero.
The arguments/options that are passed to the mache script are taken into account when checking if cache should be used. Different values will result in the mache script being re-evaluated. memoization
Requires bash-tap to be downloaded and on the $PATH.
Tests can be run with Perl's prove command; or execute a single one:
./t/printf.t # run single test
prove # run all tests1..1 # ok - Supports printf like templating. t/machetarget.t .. ok t/printf.t ....... ok t/shellcheck.t ... ok All tests successful. Files=3, Tests=5, 1 wallclock secs ( 0.02 usr 0.00 sys + 0.08 cusr 0.00 csys = 0.10 CPU) Result: PASS
Caching can result in hard to find bugs because it isn't clear which version of the output is being used. When caching, cache thoughtfully and invalidate a cache when in doubt.
Generating the documentation requires markatzea.
markatzea ./README.mz > ./README.md
GNU General Public License 3.0
| Back | FazBrowse Home | New Git URL |