workflow

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

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.
}

--- Step 2: Check for clean workspace and offer to stash ---

func (*CheckAndPromptStashStep) Description

func (s *CheckAndPromptStashStep) Description() string

func (*CheckAndPromptStashStep) Execute

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

func (*CheckAndPromptStashStep) PreCheck

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

type CheckOnMainBranchStep

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

--- Step 1: Check if on the main branch ---

func (*CheckOnMainBranchStep) Description

func (s *CheckOnMainBranchStep) Description() string

func (*CheckOnMainBranchStep) Execute

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

func (*CheckOnMainBranchStep) PreCheck

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

type CreateAndPushBranchStep

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

--- Step 4: Create and push the new branch ---

func (*CreateAndPushBranchStep) Description

func (s *CreateAndPushBranchStep) Description() string

func (*CreateAndPushBranchStep) Execute

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

func (*CreateAndPushBranchStep) PreCheck

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

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
}

--- Step 3: Update the main branch from remote ---

func (*UpdateMainBranchStep) Description

func (s *UpdateMainBranchStep) Description() string

func (*UpdateMainBranchStep) Execute

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

func (*UpdateMainBranchStep) PreCheck

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

Jump to

Keyboard shortcuts

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