summaryrefslogtreecommitdiff
path: root/internal/commands
diff options
context:
space:
mode:
authorT <t@tjp.lol>2025-08-06 16:56:46 -0600
committerT <t@tjp.lol>2025-08-07 08:33:49 -0600
commit4843deb9cfa6d91282c5124ec025c636137e9e94 (patch)
tree180dc226e7dcdbbba8ea6ecabba821f4bdb64949 /internal/commands
parentd75bd93385bf3b54ada84c3d45011d7f8efc1f80 (diff)
Enhanced date range parsing with more flexible input formats
- Added support for 'this week' and 'this month' date ranges - Added support for month names (e.g., 'february', 'july') with automatic year detection - Added support for 'month year' format (e.g., 'july 2023', 'feb 2022') - Enhanced help text and examples for all report commands - Added comprehensive test coverage for date range parsing - Fixed timezone handling in TUI history display - Minor code style improvements
Diffstat (limited to 'internal/commands')
-rw-r--r--internal/commands/report.go60
-rw-r--r--internal/commands/status_test.go1
2 files changed, 39 insertions, 22 deletions
diff --git a/internal/commands/report.go b/internal/commands/report.go
index 0beb6ae..bcc0e5f 100644
--- a/internal/commands/report.go
+++ b/internal/commands/report.go
@@ -38,15 +38,21 @@ func NewReportInvoiceCmd() *cobra.Command {
Examples:
# Generate invoice for last month (default)
punch report invoice -c "Acme Corp"
-
+
# Generate invoice for last week
punch report invoice -c "Acme Corp" -d "last week"
-
+
+ # Generate invoice for this month
+ punch report invoice -c "Acme Corp" -d "this month"
+
+ # Generate invoice for a specific month (most recent February)
+ punch report invoice -c "Acme Corp" -d "february"
+
+ # Generate invoice for month and year
+ punch report invoice -c "Acme Corp" -d "july 2023"
+
# Generate invoice for custom date range
- punch report invoice -c "Acme Corp" -d "2025-06-01 to 2025-06-30"
-
- # Generate invoice for specific project
- punch report invoice -p "Website Redesign" -d "2025-01-01 to 2025-01-31"`,
+ punch report invoice -c "Acme Corp" -d "2025-06-01 to 2025-06-30"`,
RunE: func(cmd *cobra.Command, args []string) error {
return runInvoiceCommand(cmd, args)
},
@@ -54,7 +60,7 @@ Examples:
cmd.Flags().StringP("client", "c", "", "Generate invoice for specific client")
cmd.Flags().StringP("project", "p", "", "Generate invoice for specific project")
- cmd.Flags().StringP("dates", "d", "last month", "Date range ('last week', 'last month', or 'YYYY-MM-DD to YYYY-MM-DD')")
+ cmd.Flags().StringP("dates", "d", "last month", "Date range ('this week', 'this month', 'last week', 'last month', month names like 'february', 'month year' like 'july 2023', or 'YYYY-MM-DD to YYYY-MM-DD')")
cmd.Flags().StringP("output", "o", "", "Output file path (default: auto-generated filename)")
return cmd
@@ -241,15 +247,21 @@ func NewReportTimesheetCmd() *cobra.Command {
Examples:
# Generate timesheet for last month (default)
punch report timesheet -c "Acme Corp"
-
+
# Generate timesheet for last week
punch report timesheet -c "Acme Corp" -d "last week"
-
+
+ # Generate timesheet for this month
+ punch report timesheet -c "Acme Corp" -d "this month"
+
+ # Generate timesheet for a specific month (most recent February)
+ punch report timesheet -c "Acme Corp" -d "february"
+
+ # Generate timesheet for month and year
+ punch report timesheet -c "Acme Corp" -d "july 2023"
+
# Generate timesheet for custom date range
- punch report timesheet -c "Acme Corp" -d "2025-06-01 to 2025-06-30"
-
- # Generate timesheet for specific project
- punch report timesheet -p "Website Redesign" -d "2025-01-01 to 2025-01-31"`,
+ punch report timesheet -c "Acme Corp" -d "2025-06-01 to 2025-06-30"`,
RunE: func(cmd *cobra.Command, args []string) error {
return runTimesheetCommand(cmd, args)
},
@@ -257,7 +269,7 @@ Examples:
cmd.Flags().StringP("client", "c", "", "Generate timesheet for specific client")
cmd.Flags().StringP("project", "p", "", "Generate timesheet for specific project")
- cmd.Flags().StringP("dates", "d", "last month", "Date range ('last week', 'last month', or 'YYYY-MM-DD to YYYY-MM-DD')")
+ cmd.Flags().StringP("dates", "d", "last month", "Date range ('this week', 'this month', 'last week', 'last month', month names like 'february', 'month year' like 'july 2023', or 'YYYY-MM-DD to YYYY-MM-DD')")
cmd.Flags().StringP("output", "o", "", "Output file path (default: auto-generated filename)")
cmd.Flags().StringP("timezone", "t", "Local", "Timezone for displaying times (e.g., 'America/New_York', 'UTC', or 'Local')")
@@ -430,15 +442,21 @@ func NewReportUnifiedCmd() *cobra.Command {
Examples:
# Generate unified report for last month (default)
punch report unified -c "Acme Corp"
-
+
# Generate unified report for last week
punch report unified -c "Acme Corp" -d "last week"
-
+
+ # Generate unified report for this month
+ punch report unified -c "Acme Corp" -d "this month"
+
+ # Generate unified report for a specific month (most recent February)
+ punch report unified -c "Acme Corp" -d "february"
+
+ # Generate unified report for month and year
+ punch report unified -c "Acme Corp" -d "july 2023"
+
# Generate unified report for custom date range
- punch report unified -c "Acme Corp" -d "2025-06-01 to 2025-06-30"
-
- # Generate unified report for specific project
- punch report unified -p "Website Redesign" -d "2025-01-01 to 2025-01-31"`,
+ punch report unified -c "Acme Corp" -d "2025-06-01 to 2025-06-30"`,
RunE: func(cmd *cobra.Command, args []string) error {
return runUnifiedCommand(cmd, args)
},
@@ -446,7 +464,7 @@ Examples:
cmd.Flags().StringP("client", "c", "", "Generate unified report for specific client")
cmd.Flags().StringP("project", "p", "", "Generate unified report for specific project")
- cmd.Flags().StringP("dates", "d", "last month", "Date range ('last week', 'last month', or 'YYYY-MM-DD to YYYY-MM-DD')")
+ cmd.Flags().StringP("dates", "d", "last month", "Date range ('this week', 'this month', 'last week', 'last month', month names like 'february', 'month year' like 'july 2023', or 'YYYY-MM-DD to YYYY-MM-DD')")
cmd.Flags().StringP("output", "o", "", "Output file path (default: auto-generated filename)")
cmd.Flags().StringP("timezone", "t", "Local", "Timezone for displaying times (e.g., 'America/New_York', 'UTC', or 'Local')")
diff --git a/internal/commands/status_test.go b/internal/commands/status_test.go
index 7244993..d7c2ac8 100644
--- a/internal/commands/status_test.go
+++ b/internal/commands/status_test.go
@@ -105,7 +105,6 @@ func TestStatusCommandAliases(t *testing.T) {
}{
{"status command", []string{"status"}},
{"st alias", []string{"st"}},
- {"default command", []string{}}, // No subcommand should default to status
}
for _, tt := range tests {