workflow

package
v0.4.1-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package workflow defines the steps for the kickoff workflow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValidatedBranchName

func GetValidatedBranchName(
	ctx context.Context,
	branchNameFlag string,
	cfg *config.Config,
	presenter PresenterInterface,
	gitClient *git.GitClient,
	assumeYes bool,
) (string, error)

GetValidatedBranchName is a helper function that can be used by the command before initializing the workflow. It's not a step itself.

Types

type CheckAndPromptStashStep

type CheckAndPromptStashStep struct {
	GitClient *git.GitClient
	Presenter PresenterInterface
	AssumeYes bool
	DidStash  bool // ADDED: This field will track if a stash was performed.
}

CheckAndPromptStashStep checks for a clean workspace and offers to stash changes.

func (*CheckAndPromptStashStep) Description

func (s *CheckAndPromptStashStep) Description() string

Description returns a description of the step.

func (*CheckAndPromptStashStep) Execute

func (s *CheckAndPromptStashStep) Execute(
	_ context.Context,
) error

Execute runs the step.

func (*CheckAndPromptStashStep) PreCheck

func (s *CheckAndPromptStashStep) PreCheck(ctx context.Context) error

PreCheck performs pre-execution checks.

type CheckOnMainBranchStep

type CheckOnMainBranchStep struct {
	GitClient *git.GitClient
	Presenter PresenterInterface
}

CheckOnMainBranchStep verifies that the current branch is the main branch.

func (*CheckOnMainBranchStep) Description

func (s *CheckOnMainBranchStep) Description() string

Description returns a description of the step.

func (*CheckOnMainBranchStep) Execute

func (s *CheckOnMainBranchStep) Execute(
	_ context.Context,
) error

Execute runs the step.

func (*CheckOnMainBranchStep) PreCheck

func (s *CheckOnMainBranchStep) PreCheck(ctx context.Context) error

PreCheck performs pre-execution checks.

type CreateAndPushBranchStep

type CreateAndPushBranchStep struct {
	GitClient  *git.GitClient
	BranchName string
}

CreateAndPushBranchStep creates and pushes a new branch.

func (*CreateAndPushBranchStep) Description

func (s *CreateAndPushBranchStep) Description() string

Description returns a description of the step.

func (*CreateAndPushBranchStep) Execute

func (s *CreateAndPushBranchStep) Execute(ctx context.Context) error

Execute runs the step.

func (*CreateAndPushBranchStep) PreCheck

PreCheck performs pre-execution checks.

type PresenterInterface

type PresenterInterface interface {
	Error(format string, a ...any)
	Info(format string, a ...any)
	Success(format string, a ...any)
	Detail(format string, a ...any)
	Step(format string, a ...any)
	Summary(format string, a ...any)
	Newline()
	PromptForConfirmation(prompt string) (bool, error)
	PromptForInput(prompt string) (string, error)
	Advice(format string, a ...any)
}

PresenterInterface defines the UI methods the workflow engine needs. This decouples the engine from the concrete ui.Presenter.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner manages the execution of a series of workflow steps.

func NewRunner

func NewRunner(presenter PresenterInterface, assumeYes bool) *Runner

NewRunner creates a new workflow runner.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, title string, steps ...Step) error

Run executes the entire workflow.

type Step

type Step interface {
	// Description returns a user-friendly string explaining what this step will do.
	// This is used to build the "plan" shown to the user before confirmation.
	Description() string

	// PreCheck runs any prerequisite validations before the main execution.
	// If it returns an error, the entire workflow is aborted.
	PreCheck(ctx context.Context) error

	// Execute performs the primary action of the step.
	Execute(ctx context.Context) error
}

Step represents a single, discrete, and reusable action within a larger workflow.

type UpdateMainBranchStep

type UpdateMainBranchStep struct {
	GitClient *git.GitClient
}

UpdateMainBranchStep updates the main branch from the remote.

func (*UpdateMainBranchStep) Description

func (s *UpdateMainBranchStep) Description() string

Description returns a description of the step.

func (*UpdateMainBranchStep) Execute

func (s *UpdateMainBranchStep) Execute(ctx context.Context) error

Execute runs the step.

func (*UpdateMainBranchStep) PreCheck

func (s *UpdateMainBranchStep) PreCheck(_ context.Context) error

PreCheck performs pre-execution checks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL