diff --git a/README.md b/README.md index 93d10df6fca11baf98cffaf4af1e259e9de81569..3eac37211792bf397289a1ebdf9816fd4fcd71fd 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,20 @@ # Invoice + + Generate invoices from the command line. ## Text-based User Interface ```bash -invoice +invoice generate +``` + +View the generated PDF at `invoice.pdf`, you can customize the output location +with `--output`. + +```bash +open invoice.pdf ``` ## Command Line Interface @@ -28,6 +37,8 @@ invoice generate --title "Invoice" \ --notes "For debugging purposes." ``` + + Save repeated information with environment variables: ```bash @@ -45,6 +56,7 @@ invoice generate \ --item "Yellow Rubber Duck" --quantity 5 \ --item "Special Edition Plaid Rubber Duck" --quantity 1 \ --notes "For debugging purposes." + --output duck-invoice.pdf ``` ## Installation diff --git a/demo.gif b/demo.gif new file mode 100644 index 0000000000000000000000000000000000000000..c1ea6eadd9ecf873dc5e290f996161ff51bcb8a1 Binary files /dev/null and b/demo.gif differ diff --git a/invoice.pdf b/invoice.pdf index 4f831c658eaf3586f9ffaf070852807fb124c9aa..7535364c97f31691516dadb315c4d148eabb0c39 100644 Binary files a/invoice.pdf and b/invoice.pdf differ diff --git a/invoice.tape b/invoice.tape new file mode 100644 index 0000000000000000000000000000000000000000..2ae9a88bdce17e006bc17c84d59f92d2546ad941 --- /dev/null +++ b/invoice.tape @@ -0,0 +1,18 @@ +Output out.gif + +Set Shell "bash" +Set FontSize 32 +Set Width 1200 +Set Height 600 + +Type "invoice generate --from 'Dream, Inc.' \" Enter +Type " --to 'Imagine, Inc.' \" Enter +Type " --date 'June 10, 2023' \" Enter +Type " --tax 0.13 \" Enter +Type " --discount 0.15 \" Enter +Type " --item 'Rubber Duck' \" Enter +Type " --quantity 2 \" Enter +Type " --rate 25 \" Enter +Type " --note 'For debugging purposes.'" Enter + +Sleep 5s diff --git a/main.go b/main.go index 1ba47b18e1cce9e35a7933959be8e6f4b7a1bfd1..0f2d8ecf8d5d491a1d9dc386197a7fda366d4409 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,9 @@ package main import ( _ "embed" "flag" + "fmt" "log" + "strings" "time" "github.com/signintech/gopdf" @@ -103,7 +105,16 @@ var generateCmd = &cobra.Command{ writeNotes(&pdf, note) writeTotals(&pdf, subtotal, subtotal*tax, subtotal*discount) writeFooter(&pdf, id) - return pdf.WritePdf(output) + output = strings.TrimSuffix(output, ".pdf") + ".pdf" + err = pdf.WritePdf(output) + if err != nil { + return err + } + + fmt.Printf("Generated %s\n", output) + + return nil + }, }