@@ -5,8 +5,7 @@
package cmd
import (
- "fmt"
-
+ "git.secluded.site/np/cmd/shared"
"github.com/spf13/cobra"
)
@@ -14,30 +13,27 @@ var pCmd = &cobra.Command{
Use: "p",
Short: "Check plan",
Long: `Display the current session plan (goal, description, remaining tasks)`,
- Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("[STUB] Display full plan")
- fmt.Println("Example goal title")
- fmt.Println("")
- fmt.Println("Legend: ☐ pending ⟳ in progress ☑ completed")
- fmt.Println("☑ Completed task [a1b2c3d4]")
- fmt.Println(" Example completed task description")
- fmt.Println("⟳ In progress task [e5f6g7h8]")
- fmt.Println(" Example in-progress task description")
- fmt.Println("☐ Pending task [i9j0k1l2]")
- fmt.Println(" Example pending task description")
- },
+ RunE: runPrintPlan,
}
func init() {
rootCmd.AddCommand(pCmd)
+}
- // Here you will define your flags and configuration settings.
-
- // Cobra supports Persistent Flags which will work for this command
- // and all subcommands, e.g.:
- // pCmd.PersistentFlags().String("foo", "", "A help for foo")
-
- // Cobra supports local flags which will only run when this command
- // is called directly, e.g.:
- // pCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
+func runPrintPlan(cmd *cobra.Command, args []string) error {
+ env, err := shared.Environment(cmd)
+ if err != nil {
+ return err
+ }
+
+ sessionDoc, found, err := shared.ActiveSession(cmd, env)
+ if err != nil {
+ return err
+ }
+ if !found {
+ return nil
+ }
+
+ _, err = shared.PrintPlan(cmd, env, sessionDoc.SID)
+ return err
}