Skip to content

Commit ad06f71

Browse files
committed
add force select flag
1 parent 18356a7 commit ad06f71

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

cmd/activities.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ var createCmd = &cobra.Command{
2121
return
2222
}
2323

24+
forceSelect, _ := cmd.Flags().GetBool("select")
25+
2426
// flags has highest priority
2527
projectId, err := cmd.Flags().GetInt("project")
2628
taskId, err := cmd.Flags().GetInt("task")
@@ -40,7 +42,7 @@ var createCmd = &cobra.Command{
4042
}
4143

4244
// if no flags or config, prompt
43-
if projectId == 0 {
45+
if projectId == 0 || forceSelect {
4446
options := make([]huh.Option[int], len(projects))
4547
for i, p := range projects {
4648
options[i] = huh.NewOption[int](p.Name, p.Id)
@@ -60,7 +62,7 @@ var createCmd = &cobra.Command{
6062
}
6163
}
6264

63-
if taskId == 0 {
65+
if taskId == 0 || forceSelect {
6466
options := make([]huh.Option[int], len(project.Tasks))
6567
for i, t := range project.Tasks {
6668
options[i] = huh.NewOption[int](t.Name, t.Id)
@@ -72,7 +74,7 @@ var createCmd = &cobra.Command{
7274
}
7375
}
7476

75-
if description == "" {
77+
if description == "" || forceSelect {
7678
huh.NewInput().Title("Description:").Prompt("> ").Value(&description).Run()
7779
}
7880

@@ -183,6 +185,7 @@ func init() {
183185
createCmd.Flags().IntP("task", "t", 0, "Set the task for the activity")
184186
createCmd.Flags().StringP("description", "d", "", "Set the description for the activity")
185187
createCmd.Flags().IntP("minutes", "m", 0, "Set the number of minutes for the activity")
188+
createCmd.Flags().BoolP("select", "s", false, "Force selection of project and task from list")
186189

187190
restartCmd.Flags().IntP("activity", "a", 0, "Set the activity to restart")
188191

0 commit comments

Comments
 (0)