input

package
v0.0.0-...-4047254 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package input provides user input handling and validation functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskForDistributionName

func AskForDistributionName() (string, error)

AskForDistributionName prompts the user to enter a distribution name with a default suggestion.

func AskForDistributionNameWithDefault

func AskForDistributionNameWithDefault(defaultValue string) (string, error)

AskForDistributionNameWithDefault prompts the user to enter a distribution name with a default value.

func AskForTextInput

func AskForTextInput(prompt, placeholder, defaultValue string) (string, error)

AskForTextInput prompts the user for text input with the given prompt, placeholder, and default value.

func AskForTextInputWithDescription

func AskForTextInputWithDescription(prompt, description, placeholder, defaultValue string) (string, error)

AskForTextInputWithDescription prompts the user for text input with explanatory copy.

func AskForYesNo

func AskForYesNo(question string, currentAnswer bool) (bool, error)

AskForYesNo prompts the user with a yes/no question and returns their answer.

func AskForYesNoWithDescription

func AskForYesNoWithDescription(question, description string, currentAnswer bool) (bool, error)

AskForYesNoWithDescription prompts the user with a yes/no question plus explanatory copy.

func CreateMembersConfig

func CreateMembersConfig(names []string) *config.MembersConfig

CreateMembersConfig creates a MembersConfig from a list of member names

func DisplayMemberSummary

func DisplayMemberSummary(names []string)

DisplayMemberSummary displays a summary of the members entered

func DisplayWelcomeMessage

func DisplayWelcomeMessage()

DisplayWelcomeMessage displays the welcome message for the initialization process

func GenerateMembersConfig

func GenerateMembersConfig(options Options) (*config.MembersConfig, error)

GenerateMembersConfig generates a MembersConfig based on the provided options

func GetExistingDistributions

func GetExistingDistributions() ([]string, error)

GetExistingDistributions returns a list of existing distribution directories

func LoadExistingConfiguration

func LoadExistingConfiguration() (config2.OriginConfig, error)

LoadExistingConfiguration loads the existing configuration from the default location

func ProcessMembersFromCSV

func ProcessMembersFromCSV(file *os.File) ([]string, error)

ProcessMembersFromCSV reads member names from a CSV file Expects CSV format: username,email,name,password,id Returns the username column (first column) for each row, skipping the header

func ProcessMembersFromFile

func ProcessMembersFromFile(filename string) ([]string, error)

ProcessMembersFromFile reads member names from a file

func ProcessMembersFromReader

func ProcessMembersFromReader(scanner *bufio.Scanner) ([]string, error)

ProcessMembersFromReader reads member names from a scanner

func ProcessMembersFromStdin

func ProcessMembersFromStdin() ([]string, error)

ProcessMembersFromStdin reads member names from standard input

func ProcessMembersInput

func ProcessMembersInput(input string) []string

ProcessMembersInput processes the raw text input and extracts member names

func RunInteractiveInput

func RunInteractiveInput() ([]string, error)

RunInteractiveInput starts an interactive session for member input

func RunInteractiveInputWithInitial

func RunInteractiveInputWithInitial(initialMembers []string) ([]string, error)

RunInteractiveInputWithInitial starts an interactive session for member input and preloads existing member names into the editor.

func SaveMembersConfig

func SaveMembersConfig(membersConfig *config.MembersConfig, options Options) (string, error)

SaveMembersConfig saves the members configuration to a file

Types

type Error

type Error struct {
	apperror.Carrier
	ErrorType ErrorType
	Message   string
	Err       error // Wrapped error
}

Error represents a specific error in the input package

func NewDirectoryCreateError

func NewDirectoryCreateError(err error) *Error

NewDirectoryCreateError creates an error for directory creation failures.

func NewError

func NewError(errorType ErrorType, message string, err error) *Error

NewError creates a new Error with proper categorization

func NewFileInputFailedError

func NewFileInputFailedError(err error) *Error

NewFileInputFailedError creates an error for file input failures.

func NewFileOpenError

func NewFileOpenError(err error) *Error

NewFileOpenError creates an error for file open failures.

func NewInputReadError

func NewInputReadError(err error) *Error

NewInputReadError creates an error for input read failures.

func NewInteractiveInputFailedError

func NewInteractiveInputFailedError(err error) *Error

NewInteractiveInputFailedError creates an error for interactive input failures.

func NewMembersConfigSaveError

func NewMembersConfigSaveError(err error) *Error

NewMembersConfigSaveError creates an error for members config save failures.

func NewMembersFilePathCreateError

func NewMembersFilePathCreateError(err error) *Error

NewMembersFilePathCreateError creates an error for members file path creation failures.

func NewMembersPathResolveError

func NewMembersPathResolveError(err error) *Error

NewMembersPathResolveError creates an error for members path resolution failures.

func NewNoMemberNamesError

func NewNoMemberNamesError() *Error

NewNoMemberNamesError creates an error for missing member names.

func NewProgramRunError

func NewProgramRunError(err error) *Error

NewProgramRunError creates an error for program run failures.

func NewStdinInputFailedError

func NewStdinInputFailedError(err error) *Error

NewStdinInputFailedError creates an error for stdin input failures.

func NewUnexpectedModelTypeError

func NewUnexpectedModelTypeError(modelTypeName string) *Error

NewUnexpectedModelTypeError creates an error for unexpected model type.

func NewUnknownMethodError

func NewUnknownMethodError(method Method) *Error

NewUnknownMethodError creates an error for unknown input method.

func NewUserCancelledError

func NewUserCancelledError() *Error

NewUserCancelledError creates an error for user cancellation.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorType

type ErrorType int

ErrorType defines domain-based error categories for the input package. Consolidated from 14+ specific types to 4 semantic domains.

const (
	// ErrInput indicates input operation errors.
	ErrInput ErrorType = iota

	// ErrValidation indicates validation errors.
	ErrValidation

	// ErrFilesystem indicates file system errors.
	ErrFilesystem

	// ErrUserCancelled indicates user cancellation.
	ErrUserCancelled
)

func (ErrorType) String

func (t ErrorType) String() string

String returns a human-readable name for the error type.

type ListItemType

type ListItemType int

ListItemType represents the type of item in the search results list.

const (
	// ItemTypeProjectDistro represents a project or distribution item.
	ItemTypeProjectDistro ListItemType = iota
	// ItemTypeUser represents a user item.
	ItemTypeUser
)

type ListModel

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

ListModel represents the BubbleTea model for interactive search

func NewInteractiveModel

func NewInteractiveModel(projects []Project, getMembersFunc func(projectPath string, distributionName string) ([]MemberInfo, error)) ListModel

NewInteractiveModel creates a new interactive search model

func (ListModel) Aborted

func (m ListModel) Aborted() bool

Aborted returns true if the selection was aborted

func (ListModel) Init

func (m ListModel) Init() tea.Cmd

Init initializes the model

func (ListModel) Selected

func (m ListModel) Selected() (SearchItem, bool)

Selected returns the currently selected item and true, or false when none

func (ListModel) SelectedPath

func (m ListModel) SelectedPath() string

SelectedPath returns the selected project path

func (ListModel) Update

func (m ListModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles UI updates

func (ListModel) View

func (m ListModel) View() string

View renders the UI

type Match

type Match struct {
	Type         MatchType
	Distribution string // The distribution that was matched OR the one the user was found in.
	UserName     string // If a user name matched
	UserUUID     string // If a user matched
	SearchTerm   string // The specific search term that caused this match.
}

Match stores details about what part of a project matched a search query.

type MatchType

type MatchType int

MatchType represents the type of match found during search.

const (
	// MatchTypeProject indicates a project-level match.
	MatchTypeProject MatchType = iota
	// MatchTypeDistribution indicates a distribution-level match.
	MatchTypeDistribution
	// MatchTypeUser indicates a user-level match.
	MatchTypeUser
)

type MemberInfo

type MemberInfo struct {
	Username  string
	GroupUUID string
}

MemberInfo represents member information for a project distribution

type Method

type Method int

Method represents a method for inputting member names

const (
	// InteractiveInput uses a BubbleTea UI for interactive input
	InteractiveInput Method = iota
	// FileInput reads members from a file
	FileInput
	// StdinInput reads members from standard input
	StdinInput
)

func DetermineMethod

func DetermineMethod(membersFile string) (Method, string)

DetermineMethod determines the input method based on stdin and file flags

type Model

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

Model represents the UI model for member name input

func NewModel

func NewModel() Model

NewModel creates a new model for member input

func (Model) Aborted

func (m Model) Aborted() bool

Aborted returns true if the user cancelled the input

func (Model) Error

func (m Model) Error() error

Error returns any error that occurred

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model

func (Model) Result

func (m Model) Result() string

Result returns the entered member names

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles UI updates

func (Model) View

func (m Model) View() string

View renders the UI

type Options

type Options struct {
	// Method is the input method to use
	Method Method
	// FilePath is the path to the input file (for FileInput)
	FilePath string
	// DivekitHome is the path to the divekit home directory
	DivekitHome string
	// DistributionName is the name of the current distribution
	DistributionName string
	// Target is the target being processed
	Target string
}

Options contains options for member input

type Project

type Project struct {
	Path          string
	Name          string
	Distributions []string
	Matches       []Match // To store specific info about why this project was matched.
}

Project represents a single Divekit project with its details for display. This is different from index.Project, which is for storage.

type SearchItem

type SearchItem struct {
	ItemType     ListItemType
	Project      Project
	Distribution string
	UserName     string
	GroupUUID    string
}

SearchItem is a list.Item implementation for our interactive list.

func (SearchItem) Description

func (s SearchItem) Description() string

Description returns the description text for this search item.

func (SearchItem) FilterValue

func (s SearchItem) FilterValue() string

FilterValue returns the string value used for filtering/searching this item.

func (SearchItem) Title

func (s SearchItem) Title() string

Title returns the display title for this search item.

Jump to

Keyboard shortcuts

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