@@ -26,13 +26,12 @@ var workflowGetCmd = &cobra.Command{
2626 RunE : runWorkflowGet ,
2727}
2828
29- // Steps command is currently not implemented as the method is internal
30- // var workflowStepsCmd = &cobra.Command{
31- // Use: "steps [workflow-id]",
32- // Short: "List the steps of a workflow",
33- // Args: cobra.ExactArgs(1),
34- // RunE: runWorkflowSteps,
35- // }
29+ var workflowStepsCmd = & cobra.Command {
30+ Use : "steps [workflow-id]" ,
31+ Short : "List the steps of a workflow" ,
32+ Args : cobra .ExactArgs (1 ),
33+ RunE : runWorkflowSteps ,
34+ }
3635
3736var workflowCancelCmd = & cobra.Command {
3837 Use : "cancel [workflow-id]" ,
@@ -59,7 +58,7 @@ func init() {
5958 // Add subcommands to workflow
6059 workflowCmd .AddCommand (workflowListCmd )
6160 workflowCmd .AddCommand (workflowGetCmd )
62- // workflowCmd.AddCommand(workflowStepsCmd) // Not implemented - internal method
61+ workflowCmd .AddCommand (workflowStepsCmd )
6362 workflowCmd .AddCommand (workflowCancelCmd )
6463 workflowCmd .AddCommand (workflowResumeCmd )
6564 workflowCmd .AddCommand (workflowForkCmd )
@@ -250,11 +249,60 @@ func runWorkflowGet(cmd *cobra.Command, args []string) error {
250249 return nil
251250}
252251
253- // Steps function is not implemented as the method is internal
254- // func runWorkflowSteps(cmd *cobra.Command, args []string) error {
255- // // Implementation would go here
256- // return nil
257- // }
252+ func runWorkflowSteps (cmd * cobra.Command , args []string ) error {
253+ workflowID := args [0 ]
254+
255+ // Get database URL
256+ dbURL , err := getDBURL (cmd )
257+ if err != nil {
258+ return err
259+ }
260+
261+ // Create DBOS context
262+ ctx , err := createDBOSContext (dbURL )
263+ if err != nil {
264+ return err
265+ }
266+
267+ // Get workflow steps
268+ steps , err := dbos .GetWorkflowSteps (ctx , workflowID )
269+ if err != nil {
270+ return fmt .Errorf ("failed to get workflow steps: %w" , err )
271+ }
272+
273+ // Ensure we have a non-nil slice for JSON output
274+ if steps == nil {
275+ steps = []dbos.StepInfo {}
276+ }
277+
278+ // Output results
279+ if jsonOutput {
280+ return outputJSON (steps )
281+ }
282+
283+ // Pretty print for non-JSON output
284+ if len (steps ) == 0 {
285+ logger .Info ("No steps found for workflow" , "id" , workflowID )
286+ return nil
287+ }
288+
289+ fmt .Printf ("Steps for workflow %s:\n \n " , workflowID )
290+ for _ , step := range steps {
291+ fmt .Printf ("Step %d: %s\n " , step .StepID , step .StepName )
292+ if step .Output != nil {
293+ fmt .Printf (" Output: %v\n " , step .Output )
294+ }
295+ if step .Error != nil {
296+ fmt .Printf (" Error: %v\n " , step .Error )
297+ }
298+ if step .ChildWorkflowID != "" {
299+ fmt .Printf (" Child Workflow: %s\n " , step .ChildWorkflowID )
300+ }
301+ fmt .Println ()
302+ }
303+
304+ return nil
305+ }
258306
259307func runWorkflowCancel (cmd * cobra.Command , args []string ) error {
260308 workflowID := args [0 ]
0 commit comments