make the program installable

This commit is contained in:
2026-01-22 21:17:24 -07:00
parent ef80b03029
commit 6a20f179af
4 changed files with 37 additions and 13 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
*.bak
*.pdf
last_invoice_number
*.csv

18
Makefile Normal file
View File

@@ -0,0 +1,18 @@
support_files := ${XDG_DATA_HOME}/bill-generator/
config_files:= ${XDG_CONFIG_HOME}/bill-generator/
install_loc := ~/.local/bin/
install:
mkdir -p $(support_files)
mkdir -p $(config_files)
mkdir -p $(install_loc)
cp *.mm $(support_files)
# Copy the ident file but don't overwrite one that is already there.
cp --update=none ident $(config_files)
cp gen.sh $(install_loc)/bill-gen
printf "\nInstalled!\nUpdate your identity at $(config_files)ident\n\n"
remove:
# Remove everything except the config files
rm -r $(support_files)
rm $(install_loc)bill-gen

23
gen.sh
View File

@@ -1,16 +1,14 @@
#!/bin/bash
# What you charge an hour
export RATE=50
export COMPANY_NAME="Cookies Unlimited, LLC"
export ADDR_LN_1="123 Sesasme St"
export ADDR_LN_2="Dumpster 1"
export ADDR_LN_3="12345, Nicevile, FL"
export PHONE="(123) 456-7890"
export EMAIL="cookie@exapmle.com"
DATA_HOME="$XDG_DATA_HOME/bill-generator"
source "$XDG_CONFIG_HOME/bill-generator/ident"
# Need to be set to the installed location
TEMPLATE_1COL="$DATA_HOME/1col.template.mm"
TEMPLATE_2COL="$DATA_HOME/2col.template.mm"
INV_FILE="$DATA_HOME/last_invoice_number"
print_help() {
echo "$0 -1 <hrs.csv> <Paying Company Name> [output file]"
echo "$0 -2 <hrs.csv> <items.csv> <Paying Company Name> [output file]"
echo "$(basename $0) -1 <hrs.csv> <Paying Company Name> [output file]"
echo "$(basename $0) -2 <hrs.csv> <items.csv> <Paying Company Name> [output file]"
echo ""
echo "CSV files should be <name>,<value>."
echo "CSV files should have no empty line at the end."
@@ -19,7 +17,6 @@ print_help() {
}
get_invoice_num() {
# Increment a global invoice number
INV_FILE="last_invoice_number"
INV_NUM=0
if [[ -f $INV_FILE ]]; then
INV_NUM=$(expr $(cat $INV_FILE) + 1)
@@ -58,7 +55,7 @@ if [[ $1 = "-1" ]]; then
OUTPUT=$4
fi
export COMPANY=$3
envsubst < 1col.template.mm | groff -t -mm -T pdf > $OUTPUT
envsubst < $TEMPLATE_1COL | groff -t -mm -T pdf > $OUTPUT
elif [[ $1 = "-2" ]]; then
if [[ ! -z $5 ]]; then
OUTPUT=$5
@@ -70,7 +67,7 @@ elif [[ $1 = "-2" ]]; then
export ITEM_BODY=$(cat $CONSUME_TMP | head -n -1)
export TOTAL=$(A=$HRS_COST B=$ITEM_TOTAL awk 'BEGIN{ print ENVIRON["A"] + ENVIRON["B"] }')
export COMPANY=$4
envsubst < 2col.template.mm | groff -t -mm -T pdf > $OUTPUT
envsubst < $TEMPLATE_2COL | groff -t -mm -T pdf > $OUTPUT
else
echo First arg should be either -1 or -2
fi

8
ident Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
export RATE=50
export COMPANY_NAME="Cookies Unlimited, LLC"
export ADDR_LN_1="123 Sesasme St"
export ADDR_LN_2="Dumpster 1"
export ADDR_LN_3="12345, Nicevile, FL"
export PHONE="(123) 456-7890"
export EMAIL="cookie@exapmle.com"