Compare commits

...

4 Commits

Author SHA1 Message Date
ida schmidt f87fb33508 use fsi stored in recipe 2023-08-12 01:54:32 -07:00
ida schmidt c1a93a0da2 store fsi in recipe 2023-08-12 01:06:02 -07:00
ida schmidt 6b2458ff5d minor pipline optimization 2023-08-12 01:05:07 -07:00
ida schmidt df97a5c510 fix long recipe not printing trailing newline 2023-08-12 00:18:36 -07:00
2 changed files with 10 additions and 5 deletions

View File

@ -56,20 +56,21 @@ done
shift $((OPTIND-1)) # shift options out from infront of the command to leave only arugment in $@
function panarea {
FSI="${FSI:-2.12206590789}" # default grams of Flour per Square Inch of pan, fairly neopolitan
DFSI=$(grep -A 1 "\[$RECIPE:ratios\]" "$PWD/pizza.txt" | tail -1 | cut -f 2) # find recipe's default flour per squre inch
FSI="${FSI:-$DFSI}" # dont use default fsi if already set
AREA=$(echo "3.1415926535*($DIAM/2)^2" | bc -l) # bc cant exponentiate non-integer bases without -l
SIZE=$(echo "$COUNT"*$AREA*"$FSI" | bc)
SIZE=$(echo "$COUNT"*$AREA*"$FSI" | bc -l)
arraytio
}
function arraytio { # im funny portmantaus are never bad
[ -n SIZE ] || read -p "Grams of flour: " SIZE # test ([) will send a non-zero exit code on if $SIZE doesnt exist, tripping the or (the '||')
INDEX=0
for RATIO in $(sed -n "/\[$RECIPE:ratios\]/,/^$/p" "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 2); do # finding [ratios] until the next blank line, removing the first line.
for RATIO in $(sed -n "/\[$RECIPE:ratios\]/,/^$/p" "$PWD/pizza.txt" | tail -n +3 | cut -f 2); do # finding [ratios] until the next blank line, removing the first two lines.
declare -a INGREDIENT # make arrays
declare -a MEASURE
((INDEX++)) # increment the index
INGREDIENT[$INDEX]=$(sed -n "/\[$RECIPE:ratios\]/,/^$/p" "$PWD/pizza.txt" | sed '/\[*.\]/d' | cut -f 1 | sed $INDEX'!d') # same deal but itterating through the INDEX
INGREDIENT[$INDEX]=$(sed -n "/\[$RECIPE:ratios\]/,/^$/p" "$PWD/pizza.txt" | tail -n +3 | cut -f 1 | sed $INDEX'!d') # same deal but itterating through the INDEX
MEASURE[$INDEX]=$(echo "scale = 2; ($RATIO*$SIZE)/1" | bc -l) # we have to divide by 1 to actually apply the scale
echo ${INGREDIENT[$INDEX]}: ${MEASURE[$INDEX]}g # actually print the calculated number with label for each INDEX
done
@ -97,6 +98,7 @@ case $1 in # this parses the first argument (and actually calls our main functio
panarea;;
*)
read -p "Diameter of pan (in inches): " DIAM
read -p "Flour per square inch [2.122]: " FSI
DFSI=$(grep -A 1 "\[$RECIPE:ratios\]" "$PWD/pizza.txt" | tail -1 | cut -f 2)
read -p "Flour per square inch [$DFSI]: " FSI
panarea;;
esac

View File

@ -1,4 +1,5 @@
[quick:ratios]
fsi 2.12206
flour 1
yeast 0.03333
salt 0.03333
@ -34,6 +35,7 @@ b.ex. 0.00417
11: bake at 550f until done
[long:ratios]
fsi 1.4
flour 1
water 0.5
salt 0.02
@ -51,3 +53,4 @@ oil 0.0625
7: rise for 10 minutes
8: add sauce, toppings
9: bake at 550f until done