mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-05 18:58:43 +02:00
28ba9b915b
Reviewed-on: https://gitea.com/gitea/tea/pulls/1006 Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package workflows
|
|
|
|
import (
|
|
stdctx "context"
|
|
"fmt"
|
|
|
|
"gitea.dev/tea/cmd/flags"
|
|
"gitea.dev/tea/modules/context"
|
|
"gitea.dev/tea/modules/print"
|
|
|
|
"github.com/urfave/cli/v3"
|
|
)
|
|
|
|
// CmdWorkflowsView represents a sub command to view workflow details
|
|
var CmdWorkflowsView = cli.Command{
|
|
Name: "view",
|
|
Aliases: []string{"show", "get"},
|
|
Usage: "View workflow details",
|
|
Description: "View details of a specific workflow",
|
|
ArgsUsage: "<workflow-id>",
|
|
Action: runWorkflowsView,
|
|
Flags: flags.AllDefaultFlags,
|
|
}
|
|
|
|
func runWorkflowsView(ctx stdctx.Context, cmd *cli.Command) error {
|
|
if cmd.Args().Len() == 0 {
|
|
return fmt.Errorf("workflow ID is required")
|
|
}
|
|
|
|
c, err := context.InitCommand(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := c.Ensure(context.CtxRequirement{RemoteRepo: true}); err != nil {
|
|
return err
|
|
}
|
|
client := c.Login.Client()
|
|
|
|
workflowID := cmd.Args().First()
|
|
wf, _, err := client.Actions.GetRepoWorkflow(ctx, c.Owner, c.Repo, workflowID)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to get workflow: %w", err)
|
|
}
|
|
|
|
print.ActionWorkflowDetails(wf)
|
|
return nil
|
|
}
|