From 7903d6f3576b40ac08ec252fcb99e1e8371b7fe6 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 19 Jul 2024 09:29:22 +0200 Subject: [PATCH] CLI: remove step-id and add step-number as option to logs (#3927) --- cli/internal/util.go | 21 +++++++-------------- cli/pipeline/logs.go | 5 ++--- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/cli/internal/util.go b/cli/internal/util.go index 2e8cbb63e..e705dc9f9 100644 --- a/cli/internal/util.go +++ b/cli/internal/util.go @@ -166,12 +166,10 @@ func ParseKeyPair(p []string) map[string]string { ParseStep parses the step id form a string which may either be the step PID (step number) or a step name. These rules apply: -- Step ID take precedence over step name when searching for a match. +- Step PID take precedence over step name when searching for a match. - First match is used, when there are multiple steps with the same name. Strictly speaking, this is not parsing, but a lookup. - -TODO: Use PID instead of StepID */ func ParseStep(client woodpecker.Client, repoID, number int64, stepArg string) (stepID int64, err error) { pipeline, err := client.Pipeline(repoID, number) @@ -179,20 +177,15 @@ func ParseStep(client woodpecker.Client, repoID, number int64, stepArg string) ( return 0, err } - stepID, err = strconv.ParseInt(stepArg, 10, 64) - // TODO: for 3.0 do "stepPID, err := strconv.ParseInt(stepArg, 10, 64)" + stepPID, err := strconv.ParseInt(stepArg, 10, 64) if err == nil { - return stepID, nil - /* - // TODO: for 3.0 - for _, wf := range pipeline.Workflows { - for _, step := range wf.Children { - if int64(step.PID) == stepPID { - return step.ID, nil - } + for _, wf := range pipeline.Workflows { + for _, step := range wf.Children { + if int64(step.PID) == stepPID { + return step.ID, nil } } - */ + } } for _, wf := range pipeline.Workflows { diff --git a/cli/pipeline/logs.go b/cli/pipeline/logs.go index 6ad19fc6f..f7725bc46 100644 --- a/cli/pipeline/logs.go +++ b/cli/pipeline/logs.go @@ -30,9 +30,8 @@ import ( var pipelineLogsCmd = &cli.Command{ Name: "logs", Usage: "show pipeline logs", - ArgsUsage: " [step-id|step-name]", - // TODO: for v3.0 do `ArgsUsage: " [step-number|step-name]",` - Action: pipelineLogs, + ArgsUsage: " [step-number|step-name]", + Action: pipelineLogs, } func pipelineLogs(ctx context.Context, c *cli.Command) error {