A small command-line tool written in Go to manage dealership records stored as CSV files per region.
This repository provides simple commands to list, view, create, edit, and show status for dealerships in a given region.
- Provide build & run instructions
- Document available commands and interactive behavior
- Describe the CSV storage format and sample row
- Add notes about regions and troubleshooting
- Build instructions
- Usage examples for each command
- CSV format description
- Notes and possible improvements
main.go— CLI entrypoint that parses flags and dispatches commandsdealership.go— Dealership data model and interactive command implementationsstorage.go— CSV load/save helpers (per-region files underdata/)data/— CSV files for regions (e.g.tehran.csv,fars.csv)
Make sure you have Go installed (tested with Go 1.16+). From the project root:
go build -o dealership-cli .Or run directly without building:
go run ./...The CLI accepts two flags:
-command— which command to run (one oflist,get,create,edit,status)-region— the region name (maps to a CSV filedata/<region>.csv)
Basic usage example:
./dealership-cli -command=list -region=tehran
# or with go run
go run main.go -command=list -region=tehranlist— prints a concise list of dealerships in the region.get— interactively prompts for a dealership ID and then prints detailed info.create— interactively prompts for name, phone, address, date, and employee count; saves a new record.edit— interactively prompts for an ID then allows editing each field (press Enter to keep current value).status— prints summary stats: number of dealerships and total employees.
get, create, and edit read additional input from stdin. For example:
./dealership-cli -command=get -region=tehran
# then type the ID and press Enter when promptedEach region is stored as data/<region>.csv. Each row has the following columns (in order):
- ID (int)
- Name (string)
- Address (string)
- Phone (string)
- MembershipDate (string)
- EmployeeCount (int)
Example row:
1,AutoPlus,123 Main St,+98-21-12345678,2020-01-15,12
- Regions correspond to CSV filenames. Use e.g.
-region=tehranto read/writedata/tehran.csv. - If a region file does not exist, listing returns empty results and creating a new dealership will create the file when saved.
- IDs are assigned automatically when creating new records (next-highest integer).
- The project currently stores data in plain CSV files and does not perform concurrency control.
- If you see "Usage: ./dealership-cli -command= -region=", make sure both flags are provided.
- If CSV files are not tracked in Git, check
.gitignore(this repo ignores*.csvby default). - Input validation is minimal; non-numeric ID/employee inputs will yield an error.
Ideas for future work:
- Add automated tests for CSV parsing and command logic.
- Add non-interactive flags to pass values for
create/editto support scripting. - Use a proper storage backend (SQLite, JSON, or a small REST API) instead of CSV for robustness.
- Improve validation and user-friendly error messages.
Feel free to open issues or submit PRs. Keep changes small and focused; include tests where appropriate.
This project is provided without a license file. Add a LICENSE if you want to set terms.