cli

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package cli provides the terminal user interface components for Clonr.

The package uses Bubbletea for building interactive terminal UIs and Lipgloss for styling. All UI components follow the standard Bubbletea Model-View-Update (MVU) architecture.

Components

The package provides several UI components:

  • Menu: Main interactive menu for selecting operations
  • RepoList: Filterable list of repositories with actions
  • Clone: Progress display for git clone operations
  • Configure: Configuration wizard with form navigation

Creating New Components

To create a new Bubbletea component:

  1. Define a model struct containing component state
  2. Implement Init() tea.Cmd for initialization
  3. Implement Update(tea.Msg) (tea.Model, tea.Cmd) for state updates
  4. Implement View() string for rendering

Example:

type myModel struct {
    items []string
    cursor int
}

func (m myModel) Init() tea.Cmd { return nil }
func (m myModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { ... }
func (m myModel) View() string { ... }

Styling

Use Lipgloss for consistent styling across components. Common styles are defined as package-level variables for reuse.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchListModel

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

BranchListModel is the Bubbletea model for branch listing

func NewBranchList

func NewBranchList(repoPath, repoURL string, showAll bool) (BranchListModel, error)

NewBranchList creates a new branch list model for the given repository

func (BranchListModel) GetAction

func (m BranchListModel) GetAction() string

GetAction returns the action to perform

func (BranchListModel) GetRepoPath

func (m BranchListModel) GetRepoPath() string

GetRepoPath returns the repository path

func (BranchListModel) GetSelectedBranch

func (m BranchListModel) GetSelectedBranch() *core.Branch

GetSelectedBranch returns the selected branch

func (BranchListModel) Init

func (m BranchListModel) Init() tea.Cmd

func (BranchListModel) Update

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

func (BranchListModel) View

func (m BranchListModel) View() string

type CloneModel

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

func NewCloneModel

func NewCloneModel(url, path string) CloneModel

NewCloneModel creates a new clone model Authentication is handled via clonr's credential helper

func (CloneModel) Error

func (m CloneModel) Error() error

func (CloneModel) Init

func (m CloneModel) Init() tea.Cmd

func (CloneModel) Update

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

func (CloneModel) View

func (m CloneModel) View() string

type ConfigureModel

type ConfigureModel struct {
	Saved bool
	Err   error
	// contains filtered or unexported fields
}

func NewConfigureModel

func NewConfigureModel() (ConfigureModel, error)

func (*ConfigureModel) Init

func (m *ConfigureModel) Init() tea.Cmd

func (*ConfigureModel) Update

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

func (*ConfigureModel) View

func (m *ConfigureModel) View() string

type EditorItem

type EditorItem struct {
	Name    string // Display name: "VS Code"
	Command string // Executable: "code"
	Icon    string // Optional icon
}

EditorItem represents an editor option for selection.

func (EditorItem) Description

func (e EditorItem) Description() string

func (EditorItem) FilterValue

func (e EditorItem) FilterValue() string

func (EditorItem) Title

func (e EditorItem) Title() string

type EditorListModel

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

EditorListModel is a Bubbletea model for selecting an editor.

func NewEditorList

func NewEditorList() (EditorListModel, error)

NewEditorList creates a new editor selection model with only installed editors. This includes both default editors and custom editors from the configuration.

func (EditorListModel) GetSelectedEditor

func (m EditorListModel) GetSelectedEditor() *EditorItem

GetSelectedEditor returns the selected editor or nil if none was selected.

func (EditorListModel) Init

func (m EditorListModel) Init() tea.Cmd

Init initializes the model.

func (EditorListModel) Update

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

Update handles messages and updates the model.

func (EditorListModel) View

func (m EditorListModel) View() string

View renders the model.

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

func NewMainMenu

func NewMainMenu() MainMenuModel
func (m MainMenuModel) GetChoice() string
func (m MainMenuModel) Init() tea.Cmd
func (m MainMenuModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
func (m MainMenuModel) View() string

type MirrorModel

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

MirrorModel represents the state of the mirror TUI

func NewMirrorModel

func NewMirrorModel(plan *core.MirrorPlan) *MirrorModel

NewMirrorModel creates a new mirror TUI model

func (*MirrorModel) Error

func (m *MirrorModel) Error() error

Error returns the error if the mirror failed

func (*MirrorModel) Init

func (m *MirrorModel) Init() tea.Cmd

func (*MirrorModel) Results

func (m *MirrorModel) Results() []core.MirrorResult

Results returns all mirror results

func (*MirrorModel) Update

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

func (*MirrorModel) View

func (m *MirrorModel) View() string

type ProfileItem added in v0.3.0

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

ProfileItem implements list.Item for profile selection

func (ProfileItem) Description added in v0.3.0

func (i ProfileItem) Description() string

func (ProfileItem) FilterValue added in v0.3.0

func (i ProfileItem) FilterValue() string

func (ProfileItem) Title added in v0.3.0

func (i ProfileItem) Title() string

type ProfileLoginModel

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

ProfileLoginModel is the Bubbletea model for OAuth login

func NewProfileLoginModel

func NewProfileLoginModel(name, host string, scopes []string) *ProfileLoginModel

NewProfileLoginModel creates a new profile login model

func (*ProfileLoginModel) Error

func (m *ProfileLoginModel) Error() error

Error returns any error that occurred

func (*ProfileLoginModel) Init

func (m *ProfileLoginModel) Init() tea.Cmd

Init initializes the model

func (*ProfileLoginModel) Profile

func (m *ProfileLoginModel) Profile() *model.Profile

Profile returns the created profile (after completion)

func (*ProfileLoginModel) Update

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

Update handles messages

func (*ProfileLoginModel) View

func (m *ProfileLoginModel) View() string

View renders the UI

type ProfileSelectorModel added in v0.3.0

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

ProfileSelectorModel is the TUI model for profile selection

func NewProfileSelector added in v0.3.0

func NewProfileSelector() (ProfileSelectorModel, error)

NewProfileSelector creates a new profile selector TUI

func (ProfileSelectorModel) GetSelected added in v0.3.0

func (m ProfileSelectorModel) GetSelected() *model.Profile

GetSelected returns the selected profile, or nil if none was selected

func (ProfileSelectorModel) HasProfiles added in v0.3.0

func (m ProfileSelectorModel) HasProfiles() bool

HasProfiles returns true if there are profiles to select from

func (ProfileSelectorModel) Init added in v0.3.0

func (m ProfileSelectorModel) Init() tea.Cmd

func (ProfileSelectorModel) Update added in v0.3.0

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

func (ProfileSelectorModel) View added in v0.3.0

func (m ProfileSelectorModel) View() string

type RepoListModel

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

func NewRepoList

func NewRepoList(favoritesOnly bool) (RepoListModel, error)

func (RepoListModel) GetSelectedRepo

func (m RepoListModel) GetSelectedRepo() *model.Repository

func (RepoListModel) Init

func (m RepoListModel) Init() tea.Cmd

func (RepoListModel) Update

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

func (RepoListModel) View

func (m RepoListModel) View() string

type WorkspaceItem added in v0.3.0

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

WorkspaceItem implements list.Item for workspace selection

func (WorkspaceItem) Description added in v0.3.0

func (i WorkspaceItem) Description() string

func (WorkspaceItem) FilterValue added in v0.3.0

func (i WorkspaceItem) FilterValue() string

func (WorkspaceItem) Title added in v0.3.0

func (i WorkspaceItem) Title() string

type WorkspaceRepoItem added in v0.3.0

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

WorkspaceRepoItem wraps a repository for display in the workspace view

func (WorkspaceRepoItem) Description added in v0.3.0

func (i WorkspaceRepoItem) Description() string

func (WorkspaceRepoItem) FilterValue added in v0.3.0

func (i WorkspaceRepoItem) FilterValue() string

func (WorkspaceRepoItem) Title added in v0.3.0

func (i WorkspaceRepoItem) Title() string

type WorkspaceReposModel added in v0.3.0

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

WorkspaceReposModel is the TUI model for browsing repos by workspace

func NewWorkspaceReposModel added in v0.3.0

func NewWorkspaceReposModel() (WorkspaceReposModel, error)

NewWorkspaceReposModel creates a new workspace-based repo browser

func (WorkspaceReposModel) GetCurrentWorkspace added in v0.3.0

func (m WorkspaceReposModel) GetCurrentWorkspace() *model.Workspace

GetCurrentWorkspace returns the currently viewed workspace

func (WorkspaceReposModel) GetSelectedRepo added in v0.3.0

func (m WorkspaceReposModel) GetSelectedRepo() *model.Repository

GetSelectedRepo returns the selected repository

func (WorkspaceReposModel) Init added in v0.3.0

func (m WorkspaceReposModel) Init() tea.Cmd

func (WorkspaceReposModel) Update added in v0.3.0

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

func (WorkspaceReposModel) View added in v0.3.0

func (m WorkspaceReposModel) View() string

type WorkspaceSelectorModel added in v0.3.0

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

WorkspaceSelectorModel is the TUI model for workspace selection

func NewWorkspaceSelector added in v0.3.0

func NewWorkspaceSelector(allowCreate bool) (WorkspaceSelectorModel, error)

NewWorkspaceSelector creates a new workspace selector TUI

func NewWorkspaceSelectorForClone added in v0.3.0

func NewWorkspaceSelectorForClone() (WorkspaceSelectorModel, error)

NewWorkspaceSelectorForClone creates a workspace selector that returns the active workspace if the user quits without selecting

func (WorkspaceSelectorModel) GetSelected added in v0.3.0

func (m WorkspaceSelectorModel) GetSelected() *model.Workspace

GetSelected returns the selected workspace, or nil if none was selected

func (WorkspaceSelectorModel) Init added in v0.3.0

func (m WorkspaceSelectorModel) Init() tea.Cmd

func (WorkspaceSelectorModel) IsNewWorkspace added in v0.3.0

func (m WorkspaceSelectorModel) IsNewWorkspace() bool

IsNewWorkspace returns true if a new workspace should be created

func (WorkspaceSelectorModel) Update added in v0.3.0

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

func (WorkspaceSelectorModel) View added in v0.3.0

func (m WorkspaceSelectorModel) View() string

Jump to

Keyboard shortcuts

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