Change summary
README.md | 14 +++++++++++++-
demo.gif | 0
invoice.pdf | 0
invoice.tape | 18 ++++++++++++++++++
main.go | 13 ++++++++++++-
5 files changed, 43 insertions(+), 2 deletions(-)
Detailed changes
@@ -1,11 +1,20 @@
# Invoice
+<img src="https://github.com/maaslalani/invoice/assets/42545625/f7dec601-54e5-4058-ad4c-8ef715eedfba" />
+
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."
```
+<img src="https://vhs.charm.sh/vhs-66CMd4UQuXkuxX9djHUnGX.gif" width="600" />
+
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
@@ -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
@@ -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
+
},
}