From 9bd9a0a9494d1f8d91a3f653241e7cabede24f92 Mon Sep 17 00:00:00 2001 From: Dylan Ravel Date: Thu, 2 Apr 2026 19:17:48 -0700 Subject: [PATCH 1/2] Add --project flag to milestones commands --- cmd/milestones/finish.go | 8 +++++++- cmd/milestones/start.go | 8 +++++++- cmd/milestones/status.go | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cmd/milestones/finish.go b/cmd/milestones/finish.go index cd8338d..b1020b4 100644 --- a/cmd/milestones/finish.go +++ b/cmd/milestones/finish.go @@ -10,6 +10,10 @@ import ( "github.com/spf13/cobra" ) +var ( + finishMilestoneProjectFlag string +) + func FinishCmd() *cobra.Command { cmd := &cobra.Command{ Use: "finish", @@ -25,7 +29,7 @@ func FinishCmd() *cobra.Command { } defer db.Close() - projectName, err := project.DetectConfiguredProject() + projectName, err := project.DetectConfiguredProjectWithOverride(finishMilestoneProjectFlag) if err != nil { ui.PrintError(ui.EmojiError, fmt.Sprintf("detecting project: %v", err)) os.Exit(1) @@ -73,5 +77,7 @@ func FinishCmd() *cobra.Command { }, } + cmd.Flags().StringVarP(&finishMilestoneProjectFlag, "project", "p", "", "Finish a milestone for a specific global project") + return cmd } diff --git a/cmd/milestones/start.go b/cmd/milestones/start.go index 6af6e16..32ac28e 100644 --- a/cmd/milestones/start.go +++ b/cmd/milestones/start.go @@ -10,6 +10,10 @@ import ( "github.com/spf13/cobra" ) +var ( + startMilestoneProjectFlag string +) + func StartCmd() *cobra.Command { cmd := &cobra.Command{ Use: "start [name]", @@ -26,7 +30,7 @@ func StartCmd() *cobra.Command { } defer db.Close() - projectName, err := project.DetectConfiguredProject() + projectName, err := project.DetectConfiguredProjectWithOverride(startMilestoneProjectFlag) if err != nil { ui.PrintError(ui.EmojiError, fmt.Sprintf("detecting project: %v", err)) os.Exit(1) @@ -79,5 +83,7 @@ func StartCmd() *cobra.Command { }, } + cmd.Flags().StringVarP(&startMilestoneProjectFlag, "project", "p", "", "Start a milestone for a specific global project") + return cmd } diff --git a/cmd/milestones/status.go b/cmd/milestones/status.go index c8ffdcb..5141039 100644 --- a/cmd/milestones/status.go +++ b/cmd/milestones/status.go @@ -12,6 +12,10 @@ import ( "github.com/spf13/cobra" ) +var ( + statusMilestoneProjectFlag string +) + func StatusCmd() *cobra.Command { cmd := &cobra.Command{ Use: "status", @@ -27,7 +31,7 @@ func StatusCmd() *cobra.Command { } defer db.Close() - projectName, err := project.DetectConfiguredProject() + projectName, err := project.DetectConfiguredProjectWithOverride(statusMilestoneProjectFlag) if err != nil { ui.PrintError(ui.EmojiError, fmt.Sprintf("detecting project: %v", err)) os.Exit(1) @@ -72,5 +76,7 @@ func StatusCmd() *cobra.Command { }, } + cmd.Flags().StringVarP(&statusMilestoneProjectFlag, "project", "p", "", "Get the milestone status for a specific global project") + return cmd } From 56000a42ac3f0a321a7808b43ed0645da7585a20 Mon Sep 17 00:00:00 2001 From: Dylan Ravel Date: Thu, 2 Apr 2026 19:31:11 -0700 Subject: [PATCH 2/2] Mention specified project in milestone commands --- cmd/milestones/finish.go | 4 ++-- cmd/milestones/start.go | 2 +- cmd/milestones/status.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/milestones/finish.go b/cmd/milestones/finish.go index b1020b4..2ade0ed 100644 --- a/cmd/milestones/finish.go +++ b/cmd/milestones/finish.go @@ -18,7 +18,7 @@ func FinishCmd() *cobra.Command { cmd := &cobra.Command{ Use: "finish", Short: "Finish the active milestone", - Long: `Finish the currently active milestone for the current project. This marks the milestone as completed and stops auto-tagging new time entries with it.`, + Long: `Finish the currently active milestone for the current project, or the one specified. This marks the milestone as completed and stops auto-tagging new time entries with it.`, Run: func(cmd *cobra.Command, args []string) { ui.NewlineAbove() @@ -43,7 +43,7 @@ func FinishCmd() *cobra.Command { } if activeMilestone == nil { - ui.PrintError(ui.EmojiError, "No active milestone found") + ui.PrintError(ui.EmojiError, fmt.Sprintf("No active milestone found for %s", projectName)) ui.PrintMuted(0, "Use 'tmpo milestone start' to start a new milestone.") ui.NewlineBelow() os.Exit(1) diff --git a/cmd/milestones/start.go b/cmd/milestones/start.go index 32ac28e..92fea4a 100644 --- a/cmd/milestones/start.go +++ b/cmd/milestones/start.go @@ -18,7 +18,7 @@ func StartCmd() *cobra.Command { cmd := &cobra.Command{ Use: "start [name]", Short: "Start a new milestone", - Long: `Start a new milestone for the current project. Time entries created after starting a milestone will be automatically tagged with it.`, + Long: `Start a new milestone for the current project, or the one specified. Time entries created after starting a milestone will be automatically tagged with it.`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { ui.NewlineAbove() diff --git a/cmd/milestones/status.go b/cmd/milestones/status.go index 5141039..ce075e6 100644 --- a/cmd/milestones/status.go +++ b/cmd/milestones/status.go @@ -20,7 +20,7 @@ func StatusCmd() *cobra.Command { cmd := &cobra.Command{ Use: "status", Short: "Show active milestone status", - Long: `Display information about the currently active milestone for the current project.`, + Long: `Display information about the currently active milestone for the current project, or the one specified.`, Run: func(cmd *cobra.Command, args []string) { ui.NewlineAbove() @@ -45,7 +45,7 @@ func StatusCmd() *cobra.Command { } if activeMilestone == nil { - ui.PrintWarning(ui.EmojiWarning, "No active milestone") + ui.PrintError(ui.EmojiError, fmt.Sprintf("No active milestone found for %s", projectName)) ui.PrintMuted(0, "Use 'tmpo milestone start' to start a new milestone.") ui.NewlineBelow() return