Compare commits

...

2 Commits

Author SHA1 Message Date
ida schmidt 74b7c0211a add help/options 2023-04-25 05:05:33 -07:00
ida schmidt ac16a43f44 add argumentation 2023-04-25 04:11:28 -07:00
1 changed files with 41 additions and 3 deletions

View File

@ -1,9 +1,31 @@
#!/usr/bin/env bash
FSI=2.12206590789 # grams of Flour per Square Inch of pan
FSI=2.12206590789 # grams of flour per square inch of pan
function pizzahelp {
echo "Pizza Calculator: The pizza script you never asked for"
echo
echo "Usage: ./pizza.sh [-h] [-f] [<flour weight>g|<pan diameter>(in|inch|\")]"
echo "Options:"
echo " -h Print this help"
echo " -f <N> Set flour per square inch"
echo
}
while getopts ":hf:" option; do
case $option in
h)
pizzahelp
exit;;
f)
FSI=$OPTARG
shift 2;;
\?)
echo "Error: Invalid option"
exit;;
esac
done
function panarea {
read -p "Diameter of pan (in inches): " DIAM
AREA=$(echo "3.1415926535*($DIAM/2)^2" | bc)
SIZE=$(echo $AREA*$FSI | bc)
calcratio
@ -19,4 +41,20 @@ function calcratio {
done
}
panarea
case $1 in
*g)
SIZE=$(echo $1 | sed s/g//g)
calcratio;;
*\")
DIAM=$(echo $1 | sed s/\"//g)
panarea;;
*inch)
DIAM=$(echo $1 | sed s/inch//g)
panarea;;
*in)
DIAM=$(echo $1 | sed s/in//g)
panarea;;
*)
read -p "Diameter of pan (in inches): " DIAM
panarea;;
esac