A Command-Line Interface (CLI) tool for tracking and managing personal expenses. It allows users to add expenses, delete records, view expense history, and generate summaries. The sample solution for the expense-tracker challenge from roadmap.sh.
To use the Expense Tracker CLI, you need to have Go installed on your machine.
Clone the Repository:
git clone https://github.com/fhasnur/expense-tracker.gitNavigate to the project directory:
cd expense-trackerInstall the required Go modules::
go mod tidyBuild the CLI:
go build -o task-cliOnce built, you can run the CLI tool from your terminal. Below are the example commands:
./expense-tracker add --description "Lunch" --amount 20
# Expense added successfully (ID: 1)./expense-tracker list
# ID | Date/Time | Description | Amount
# -------------------------------------------------------
# 1 | 2024-09-24 23:06 | Lunch | $20
# 2 | 2024-09-30 18:31 | Dinner | $10
# 3 | 2024-10-02 18:58 | Shopping | $30./expense-tracker delete --id 1
# Expense deleted successfully./expense-tracker summary
# Total expenses: $60./expense-tracker summary --month 10
# Total expenses for October: $30Expenses are stored in a JSON file located at expenses.json in the root folder. Each expense entry is structured as follows:
{
"id": 1,
"description": "Lunch",
"amount": 20,
"created_at": "2024-09-24T23:06:02.7613895+07:00",
"updated_at": "2024-09-24T23:06:02.7613895+07:00"
}Feel free to submit pull requests or open issues for new features, improvements, or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.