3 releases
| new 0.2.2 | Apr 7, 2026 |
|---|---|
| 0.2.1 | Apr 7, 2026 |
| 0.2.0 | Aug 8, 2025 |
| 0.1.0 |
|
#545 in Finance
21KB
325 lines
The sales crate provides a command-line tool, and library, for reporting and aggregating sales data (for example, from CSV files).
Installation
cargo install sales
Usage
Download your sales data for the relevant period to a file, for example, data.csv, and run:
sales data.csv
Example output:
Product / Group Units Revenue
------------------------------------------------------------------------
Go mentoring 11 3134.45
Code For Your Life 2 79.90
For the Love of Go (2023) 1 39.95
For the Love of Go: Video/Book Bundle (2023 edition) 1 74.95
The Power of Go: Tests 1 39.95
The Power of Go: Tools 1 39.95
------------------------------------------------------------------------
Total 17 3409.15
Sorting by revenue
The default sorting is by unit sales, descending, and then alphabetically. To sort by revenue instead, use the --revenue flag:
sales --revenue data.csv
Product / Group Units Revenue
------------------------------------------------------------------------
Go mentoring 11 3134.45
Code For Your Life 2 79.90
For the Love of Go: Video/Book Bundle (2023 edition) 1 74.95
For the Love of Go (2023) 1 39.95
The Power of Go: Tests 1 39.95
The Power of Go: Tools 1 39.95
------------------------------------------------------------------------
Total 17 3409.15
Grouping related products
To aggregate the sales data for a group of related products, create a group specification file with the following format:
GROUP_NAME | GROUP_REGEX
A simple example, which groups two sets of products by matching shared substrings in their names:
For the Love of Go | For the Love
Power of Go Series | The Power of Go
Use the --groups flag to apply this group specification, and rerun the tool to see the result:
sales --groups groups.txt data.csv
Product / Group Units Revenue
--------------------------------------
Go mentoring 11 3134.45
Code For Your Life 2 79.90
For the Love of Go 2 114.90
Power of Go Series 2 79.90
--------------------------------------
Total 17 3409.15
Input formats
sales can interpret CSV data produced by Squarespace, Gumroad, and similar platforms. It reads only the product name, price, and quantity columns.
-
The product name column heading should be "Lineitem name" or "Item Name".
-
The product price column heading should be "Lineitem price" or "Item Price ($)".
-
The product quantity column heading should be "Lineitem quantity" or "Quantity".
Dependencies
~4.5–7MB
~112K SLoC