utils

package
v0.0.0-...-5b04adf Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddProject

func AddProject(workingPath string) error

AddProject adds JSON representation of new project in ~/.pms.json

func ConfigPath

func ConfigPath() string

ConfigPath returns the path of the config file

func DeleteProjet

func DeleteProjet(projectPath string) error

DeleteProjet deletes JSON representation of project from ~/.pms.json

func ReadConfig

func ReadConfig() (c config)

ReadConfig returns go struct of config file at ~/.pms.json

func UpdateProjectList

func UpdateProjectList(projectPath string) error

UpdateProjectList writes JSON representation of projects to ~/.pms.json

Types

type Model

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

Main Model

func NewModel

func NewModel() *Model

NewModel returns a new Model with some sane defaults.

func (Model) DeleteItem

func (m Model) DeleteItem() error

DeleteItem deletes the selected project from the config file.

func (*Model) Init

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

func (*Model) InitList

func (m *Model) InitList(width, height int)

InitList initializes the list with the projects from the config file.

func (Model) OpenInEditor

func (m Model) OpenInEditor() error

OpenInEditor opens the selected project in the default editor.

func (*Model) Update

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

Update updates the model on an event like a key press. Also sets the TUI window size.

func (Model) UpdateList

func (m Model) UpdateList() error

UpdateList updates the list with the selected project on top.

func (Model) View

func (m Model) View() string

View renders the list.

type Project

type Project struct {
	ProjectName string `json:"Name"`
	ProjectPath string `json:"Path"`
}

Custom Type

func (Project) Description

func (p Project) Description() string

Description returns the path of the project.

func (Project) FilterValue

func (p Project) FilterValue() string

FilterValue allows us to filter the options by name.

func (Project) Title

func (p Project) Title() string

Title returns the name of the project.

Jump to

Keyboard shortcuts

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