From c869d13a6ff83a5e9e0dfc0578e53868de345671 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 31 Jul 2026 00:39:21 -0400 Subject: [PATCH] pipeline/logs: infer latest pipeline --- internal/cli/pipeline_logs.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/internal/cli/pipeline_logs.go b/internal/cli/pipeline_logs.go index 109a19a..988a760 100644 --- a/internal/cli/pipeline_logs.go +++ b/internal/cli/pipeline_logs.go @@ -22,22 +22,33 @@ func newPipelineLogsCommand(service *app.Service) *cobra.Command { var workflows []string command := &cobra.Command{ - Use: "logs ", + Use: "logs [id]", Short: "Stream pipeline logs", Long: `Stream log output from a pipeline in real time. -If --repo is not set, the repository is detected from the current directory's -git origin remote. Use --workflow to filter to specific workflows.`, - Args: cobra.ExactArgs(1), +If no pipeline ID is given, streams the latest pipeline for the repository. If +--repo is not set, the repository is detected from the current directory's git +origin remote. Use --workflow to filter to specific workflows.`, + Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { target, err := resolveTargetFlag(cmd.Context(), repository, service) if err != nil { return err } + pipelineID := "" + if len(args) > 0 { + pipelineID = args[0] + } else { + status, err := service.PipelineStatus(cmd.Context(), target) + if err != nil { + return err + } + pipelineID = status.Pipeline.ID + } jsonOutput, _ := cmd.Flags().GetBool("json") out := cmd.OutOrStdout() terminal := isTerminal(out) - return service.PipelineLogs(cmd.Context(), target, args[0], workflows, func(event app.PipelineLogEvent) error { + return service.PipelineLogs(cmd.Context(), target, pipelineID, workflows, func(event app.PipelineLogEvent) error { if jsonOutput { return json.NewEncoder(out).Encode(event) } -- 2.51.2