-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommand_plan_next_step.go
More file actions
65 lines (53 loc) · 1.59 KB
/
command_plan_next_step.go
File metadata and controls
65 lines (53 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package tasked
import (
"fmt"
"github.com/dhamidi/tasked/planner"
"github.com/spf13/cobra"
)
var PlanNextStepCmd = &cobra.Command{
Use: "next-step <plan-name>",
Short: "Show the next incomplete step in a plan",
Long: `Display the next incomplete step in a plan. Shows the step ID, description,
and acceptance criteria. If all steps are completed, indicates the plan is done.`,
Args: cobra.ExactArgs(1),
RunE: RunPlanNextStep,
}
func RunPlanNextStep(cmd *cobra.Command, args []string) error {
planName := args[0]
// Get the database file path from settings
dbPath := GlobalSettings.GetDatabaseFile()
// Initialize the planner
p, err := planner.New(dbPath)
if err != nil {
return fmt.Errorf("failed to initialize planner: %w", err)
}
defer p.Close()
// Get the plan from the database
plan, err := p.Get(planName)
if err != nil {
return fmt.Errorf("failed to get plan: %w", err)
}
// Get the next step
nextStep := plan.NextStep()
if nextStep == nil {
fmt.Printf("Plan '%s' is completed - all steps are done!\n", planName)
return nil
}
// Display the next step details
fmt.Printf("Next step: %s\n", nextStep.ID())
fmt.Printf("Status: %s\n", nextStep.Status())
fmt.Printf("\n%s\n", nextStep.Description())
if len(nextStep.AcceptanceCriteria()) > 0 {
fmt.Printf("\nAcceptance Criteria:\n")
for i, criterion := range nextStep.AcceptanceCriteria() {
fmt.Printf("%d. %s\n", i+1, criterion)
}
}
if len(nextStep.References()) > 0 {
fmt.Printf("\nReferences:\n")
for i, reference := range nextStep.References() {
fmt.Printf("%d. %s\n", i+1, reference)
}
}
return nil
}