makes
makes copied to clipboard
Select option widget
since the following was a bit contrived to find, maybe we can add a simple select option widget for semi-interactive runbooks...
function select_iogo_job {
local string=""
info "Please select the nomad job(s) that you deployed with iogo"
PS3="Please enter: "
select opt in routing front back signer rabbit patroni Ok Abort; do
case $REPLY in
1 | 2 | 3 | 4 | 5 | 6)
string="${string}-$opt"
;;
7)
break
;;
8)
info Aborting
exit
;;
*) echo "invalid node $REPLY";;
esac
done
echo "$string"
}
Any ideas?
We currently have these two
- https://github.com/fluidattacks/makes#tobasharray
- https://github.com/fluidattacks/makes#tobashmap I suppose we can write a third that does something like this:
let
mySelect = toBashSelect {
prompt = "pick whatever you want";
options = [ "routing" "front" ... ];
};
in
{ ... }
source "${envMySelect}/template" local selected_options # derivations
source __argMySelect__/template local selected_options # templates
echo "${selected_options[@]}" # routing front .., whatever the user selected during the prompt
break and abort are automatically injected
also maybe toBashSelectMany, toBashSelectOne
or toBashSelect and a few options like:
- allowMultipleAnswers ? bool
- allowRepeatedAnswers ? bool
- minimumSelections ? int
The last suggestion seems best! Great conceptualization, thanks! I was a bit struggling on this one and I figured this might be the point where users start asking for a proper scripting language. My hope is we can extend bash's reach just another bit for most devops use cases...
is there a language you have in mind that covers all the use cases we have now + being a "proper" scripting language?
Actually any language has the same problem: you can't paste them 1-by-1 on any dev's cli.
That's probably the single biggest advantage with bash in this devops case...