Repository navigation
Build ordercli — CLI app for order management (create, view, list) #1
Description
Summary
Build a CLI application called ordercli that allows creating, viewing, and listing orders. This is the first entry point into the OMS and should follow DDD principles as defined in CLAUDE.md. Orders are persisted to a local store so they survive process restarts.
Details
CLI Commands
| Command | Description |
|---|---|
ordercli create --customer <id> --item "productId,quantity,unitPrice" [--item ...] |
Create a new order |
ordercli view --id <orderId> |
View a single order by ID |
ordercli list |
List all orders |
Line Items
- Passed as repeated
--itemflags in the format"productId,quantity,unitPrice" - Example:
--item "PROD01,3,10.00" --item "PROD02,2,25.00"
Output Format
All output is JSON for machine readability. Every response has a "status" field ("success" or "error").
Order ID Generation
- Auto-generated sequential IDs:
ORD-0001,ORD-0002, etc.
Order Status
- All newly created orders start with status
"DRAFT"
Persistence
- Orders must persist across process restarts (use a local file-based store, e.g. JSON file)
Validation Rules
| Rule | Error message |
|---|---|
Missing --customer flag |
"Customer ID is required" |
No --item flags provided |
"At least one line item is required" |
| Quantity is zero or negative | "Invalid quantity for {productId}: must be greater than 0" |
| Unit price is negative | "Invalid unit price for {productId}: must be >= 0" |
| Duplicate product ID across items | "Duplicate product ID: {productId}" |
| Malformed item format (not 3 parts) | "Invalid item format '{raw}': expected 'productId,quantity,unitPrice'" |
Calculated Fields
subtotalper line item =quantity * unitPricetotalon order = sum of all subtotalscreatedAt= ISO 8601 timestamp at time of creation
Scope
- Domain layer:
Orderaggregate,OrderLineItemvalue object, order validation invariants - Application layer: CreateOrder, ViewOrder, ListOrders use cases
- Infrastructure layer: File-based order repository, CLI argument parsing
- Follow DDD project structure as defined in CLAUDE.md:
src/order/domain/,src/order/application/,src/order/infrastructure/,src/order/api/
Verification Tests
Run these commands in sequence to verify correctness:
Test 1: Happy path — single item
ordercli create --customer "CUST001" --item "PROD01,3,10.00"{
"status": "success",
"order": {
"orderId": "ORD-0001",
"customerId": "CUST001",
"status": "DRAFT",
"items": [
{"productId": "PROD01", "quantity": 3, "unitPrice": 10.00, "subtotal": 30.00}
],
"total": 30.00,
"createdAt": "2026-02-15T12:00:00Z"
}
}Test 2: Happy path — multiple items
ordercli create --customer "CUST001" --item "PROD01,3,10.00" --item "PROD02,2,25.00"{
"status": "success",
"order": {
"orderId": "ORD-0002",
"customerId": "CUST001",
"status": "DRAFT",
"items": [
{"productId": "PROD01", "quantity": 3, "unitPrice": 10.00, "subtotal": 30.00},
{"productId": "PROD02", "quantity": 2, "unitPrice": 25.00, "subtotal": 50.00}
],
"total": 80.00,
"createdAt": "2026-02-15T12:00:01Z"
}
}Test 3: No line items
ordercli create --customer "CUST001"{"status": "error", "error": "At least one line item is required"}Test 4: Zero quantity
ordercli create --customer "CUST001" --item "PROD01,0,10.00"{"status": "error", "error": "Invalid quantity for PROD01: must be greater than 0"}Test 5: Negative quantity
ordercli create --customer "CUST001" --item "PROD01,-2,10.00"{"status": "error", "error": "Invalid quantity for PROD01: must be greater than 0"}Test 6: Negative price
ordercli create --customer "CUST001" --item "PROD01,3,-5.00"{"status": "error", "error": "Invalid unit price for PROD01: must be >= 0"}Test 7: Missing customer
ordercli create --item "PROD01,3,10.00"{"status": "error", "error": "Customer ID is required"}Test 8: Duplicate product ID
ordercli create --customer "CUST001" --item "PROD01,3,10.00" --item "PROD01,2,10.00"{"status": "error", "error": "Duplicate product ID: PROD01"}Test 9: Malformed item format
ordercli create --customer "CUST001" --item "PROD01,3"{"status": "error", "error": "Invalid item format 'PROD01,3': expected 'productId,quantity,unitPrice'"}Test 10: View order
ordercli view --id "ORD-0001"{
"status": "success",
"order": {
"orderId": "ORD-0001",
"customerId": "CUST001",
"status": "DRAFT",
"items": [
{"productId": "PROD01", "quantity": 3, "unitPrice": 10.00, "subtotal": 30.00}
],
"total": 30.00,
"createdAt": "2026-02-15T12:00:00Z"
}
}Test 11: View non-existent order
ordercli view --id "ORD-9999"{"status": "error", "error": "Order not found: ORD-9999"}Test 12: List orders
ordercli list{
"status": "success",
"orders": [
{"orderId": "ORD-0001", "customerId": "CUST001", "status": "DRAFT", "total": 30.00, "createdAt": "2026-02-15T12:00:00Z"},
{"orderId": "ORD-0002", "customerId": "CUST001", "status": "DRAFT", "total": 80.00, "createdAt": "2026-02-15T12:00:01Z"}
],
"count": 2
}Test 13: List when empty (fresh DB)
ordercli list{"status": "success", "orders": [], "count": 0}Test 14: Persistence across restart
ordercli create --customer "CUST001" --item "PROD01,1,5.00"
# restart / kill and relaunch process
ordercli list
# Expected: the created order appears in the list
Activity
Add ordercli — CLI app for order management (create, view, list)
github-actions commentedon Feb 15, 2026
Implementation Complete
Branch
cursor/issue-1has been pushed with the fullordercliimplementation following DDD principles.What was built
src/order/domain/Orderaggregate root,OrderLineItemvalue object,OrderRepositoryinterfacesrc/order/application/CreateOrder,ViewOrder,ListOrdersuse casessrc/order/infrastructure/FileOrderRepository— JSON file persistencesrc/order/api/Features
create,view,listORD-0001,ORD-0002, ...)statusfield~/.oms-5k/orders.json)Verification
All 14 verification tests from the issue pass successfully.
PR creation
The GitHub Actions token does not have permission to create pull requests in this repository. Please create the PR manually from branch
cursor/issue-1→main:👉 Create Pull Request
anujkumar-df commentedon Feb 15, 2026
I want to use Python, create a new branch, and implement the requirements.
Add ordercli Python implementation with DDD architecture (#1)
github-actions commentedon Feb 15, 2026
Python Implementation Complete
As requested, the
ordercliCLI has been re-implemented in Python on branchcursor/issue-1-python.What was built
src/order/domain/Orderaggregate root,OrderLineItemvalue object,OrderRepositoryinterfacesrc/order/application/CreateOrder,ViewOrder,ListOrdersuse casessrc/order/infrastructure/FileOrderRepository— JSON file persistence (~/.oms-5k/orders.json)src/order/api/Installation
Verification
All 14 verification tests from the issue pass successfully.
PR
The GitHub Actions token does not have permission to create pull requests. Please create the PR manually from branch
cursor/issue-1-python→main:👉 Create Pull Request