discover

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package discover provides the "sley discover" command which scans for version sources (both .version files and manifest files like package.json, Cargo.toml, etc.) and helps users understand their project structure and configure dependency-check syncing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoverAndSuggest

func DiscoverAndSuggest(ctx context.Context, cfg *config.Config, rootDir string) (*discovery.Result, *config.DependencyCheckConfig, error)

DiscoverAndSuggest is a helper function that performs discovery and returns suggested dependency-check configuration.

func GenerateDependencyCheckConfig

func GenerateDependencyCheckConfig(candidates []discovery.SyncCandidate) *config.DependencyCheckConfig

GenerateDependencyCheckConfig generates the full dependency check config from candidates.

func GenerateDependencyCheckFileConfig

func GenerateDependencyCheckFileConfig(c discovery.SyncCandidate) config.DependencyFileConfig

GenerateDependencyCheckFileConfig generates a config.DependencyFileConfig from a SyncCandidate.

func GetFieldForManifest

func GetFieldForManifest(filename string, format parser.Format) string

GetFieldForManifest returns the appropriate field path for a manifest file.

func Run

func Run(cfg *config.Config) *cli.Command

Run returns the "discover" command.

func SuggestDependencyCheckFromDiscovery

func SuggestDependencyCheckFromDiscovery(result *discovery.Result) *config.DependencyCheckConfig

SuggestDependencyCheckFromDiscovery analyzes discovery results and suggests dependency-check configuration if appropriate.

Types

type Formatter

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

Formatter handles display of discovery results.

func NewFormatter

func NewFormatter(format OutputFormat) *Formatter

NewFormatter creates a new Formatter with the specified output format.

func NewFormatterWithConfig added in v0.13.0

func NewFormatterWithConfig(format OutputFormat, cfg *config.Config) *Formatter

NewFormatterWithConfig creates a new Formatter with the specified output format and config. The config is used to adjust output severity (e.g., independent versioning shows info instead of warnings).

func (*Formatter) FormatResult

func (f *Formatter) FormatResult(result *discovery.Result) string

FormatResult formats the discovery result for display.

func (*Formatter) PrintResult

func (f *Formatter) PrintResult(result *discovery.Result)

PrintResult prints the formatted result to stdout.

type OutputFormat

type OutputFormat string

OutputFormat controls how discovery results are displayed.

const (
	// FormatText outputs human-readable text.
	FormatText OutputFormat = "text"

	// FormatJSON outputs machine-readable JSON.
	FormatJSON OutputFormat = "json"

	// FormatTable outputs tabular data.
	FormatTable OutputFormat = "table"
)

func ParseOutputFormat

func ParseOutputFormat(s string) OutputFormat

ParseOutputFormat converts a string to OutputFormat.

type Prompter

type Prompter interface {
	Confirm(title, description string) (bool, error)
	MultiSelect(title, description string, options []huh.Option[string], defaults []string) ([]string, error)
	Select(title, description string, options []huh.Option[string]) (string, error)
}

Prompter abstracts interactive prompts for testability.

func NewPrompter

func NewPrompter() Prompter

NewPrompter creates a new TUIPrompter.

type TUIPrompter

type TUIPrompter struct{}

TUIPrompter implements Prompter using the tui package.

func (*TUIPrompter) Confirm

func (p *TUIPrompter) Confirm(title, description string) (bool, error)

Confirm shows a yes/no confirmation prompt.

func (*TUIPrompter) MultiSelect

func (p *TUIPrompter) MultiSelect(title, description string, options []huh.Option[string], defaults []string) ([]string, error)

MultiSelect shows a multi-select prompt.

func (*TUIPrompter) Select added in v0.10.0

func (p *TUIPrompter) Select(title, description string, options []huh.Option[string]) (string, error)

Select shows a single-select prompt.

type Workflow

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

Workflow handles the interactive discovery workflow.

func NewWorkflow

func NewWorkflow(prompter Prompter, result *discovery.Result, rootDir string) *Workflow

NewWorkflow creates a new workflow handler.

func NewWorkflowWithConfig added in v0.13.0

func NewWorkflowWithConfig(prompter Prompter, result *discovery.Result, rootDir string, cfg *config.Config) *Workflow

NewWorkflowWithConfig creates a new workflow handler with config awareness.

func (*Workflow) Run

func (w *Workflow) Run(ctx context.Context) (bool, error)

Run executes the interactive workflow if appropriate. Returns true if the workflow completed with actions taken.

type WorkspaceChoice added in v0.10.0

type WorkspaceChoice string

WorkspaceChoice represents the user's choice for multi-module configuration.

const (
	// WorkspaceChoiceCoordinated syncs all .version files to root (coordinated versioning).
	WorkspaceChoiceCoordinated WorkspaceChoice = "coordinated"
	// WorkspaceChoiceWorkspace configures independent module versions (workspace mode).
	WorkspaceChoiceWorkspace WorkspaceChoice = "workspace"
	// WorkspaceChoiceSingleRoot uses only the root .version for all manifests.
	WorkspaceChoiceSingleRoot WorkspaceChoice = "single"
)

Jump to

Keyboard shortcuts

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