Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cmd/milestones/finish.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import (
"github.com/spf13/cobra"
)

var (
finishMilestoneProjectFlag string
)

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()

Expand All @@ -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)
Expand All @@ -39,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)
Expand Down Expand Up @@ -73,5 +77,7 @@ func FinishCmd() *cobra.Command {
},
}

cmd.Flags().StringVarP(&finishMilestoneProjectFlag, "project", "p", "", "Finish a milestone for a specific global project")

return cmd
}
10 changes: 8 additions & 2 deletions cmd/milestones/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ import (
"github.com/spf13/cobra"
)

var (
startMilestoneProjectFlag string
)

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()
Expand All @@ -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)
Expand Down Expand Up @@ -79,5 +83,7 @@ func StartCmd() *cobra.Command {
},
}

cmd.Flags().StringVarP(&startMilestoneProjectFlag, "project", "p", "", "Start a milestone for a specific global project")
Comment thread
DylanDevelops marked this conversation as resolved.

return cmd
}
12 changes: 9 additions & 3 deletions cmd/milestones/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ import (
"github.com/spf13/cobra"
)

var (
statusMilestoneProjectFlag string
)

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()

Expand All @@ -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)
Expand All @@ -41,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
Expand Down Expand Up @@ -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
}
Loading