Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: add tool functions for logging to
bump.sh
(#67)
* add tool logging functions * replace all the `echo`s by the new tool functions The following `nushell` little script have been used to replace them automatically ```bash let file = "scripts/bump.sh" [ [token tool]; ["\\+" info] [~ warning] [! error] [i ok] [- normal] ["\\?" hint] ] | each {|it| # replace "echo '[.] " or 'echo "[.] ' by the right log function sd $"echo \('|\"\)\\[($it.token)\\] " $"log_($it.tool) $1" $file } ``` One can see that all the `echo`s have been replaced by looking at ```bash > rg "echo .\\[.\\]" scripts/bump.sh ``` before and after the replacement above. * change the colors to make more sense * add ";" to all `log_*` functions This commits helps mitigate the following error ```bash > ./scripts/bump.sh ./scripts/bump.sh: line 159: syntax error: unexpected end of file ``` The `bash` interpreter needs a ";" at the end of the lines inside a oneline `{ ... }` block, just as in the `log_*` functions. Otherwise, the parser does not know where the line ends, throwing the error above. * wrap `$1` inside quotes in the `log_*` functions This commit helps mitigate the following error ```bash > DRY_RUN="yes" ./scripts/bump.sh [i] Current [-] Exactly [?] Example: [?] see ``` i.e. the `log_*` functions only print the first word they are being given... This is because of the `log_any ... $1`, as `log_any` takes the `$3` only and not everything after the fourth argument. Writing `log_any ... "$1"` makes sure the `$3` argument is made of all the message and not the first word only!! With this commit, the output of the same command as above is now ```bash > DRY_RUN="yes" ./scripts/bump.sh [i] Current directory is repo's root OK [-] Exactly one argument is needed, got 0. [?] Example: `./bump.sh 0.2.6` [?] see https://github.com/iScsc/iscsc.fr/wiki/Version-bump-procedure#automatic-version-bump for full documentation ``` * swap "info" and "ok" * remove "normal" and use "error" only, with "-" * swap the colors of "info" and "ok" This change comes from the comment of @ctmbl in #67.
- Loading branch information