core

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithConfig

func WithConfig(config *config.Config) func(*Core)

Optional function to set the config of the Core when creating a new instance.

func WithMsgChan

func WithMsgChan(msgChan *chan common.Msg) func(*Core)

Optional function to set the message channel of the Core when creating a new instance.

Types

type Commands

type Commands map[string]string

Commands is a map of command names to their Commands.

type Core

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

Core is the main struct for the core package.

It contains the config, message channel, commands and projects. The config is used to read and update the configuration. The message channel is used to send messages to the CLI or the app.

func New

func New(options ...func(*Core)) *Core

Create a new Core instance with the given options.

func (*Core) AddCommand

func (c *Core) AddCommand(name string, command string) common.Msg

Add a command with the given name and command string.

func (*Core) AddCommandToProject

func (c *Core) AddCommandToProject(projectName string, commandName string) common.Msg

Add a command to the project with the given name.

func (*Core) AddDomainAlias added in v0.7.0

func (c *Core) AddDomainAlias(projectName string, domainAlias string) common.Msg

Add a domain alias to the given project.

func (*Core) AddProject

func (c *Core) AddProject(name string, domain string, port int, commandNames []string) common.Msg

Add a project with the given name, domain, port and command names.

func (*Core) AddVariable

func (c *Core) AddVariable(projectName string, key string, value string) common.Msg

Add a variable with the given key and value to the project with the given name.

func (*Core) CommandExists added in v0.6.0

func (c *Core) CommandExists(name string) (bool, string)

Check if a command with the given name exists. Returns the command if it exists.

func (*Core) GetCommandNames

func (c *Core) GetCommandNames() []string

Get all the names of the commands.

func (*Core) GetCommands

func (c *Core) GetCommands() (Commands, error)

Get the commands from the commands.json file.

func (*Core) GetCommandsConfig

func (c *Core) GetCommandsConfig() error

Get the commands from the commands.json file.

func (*Core) GetConfig added in v0.8.0

func (c *Core) GetConfig() *config.Config

Get the config of the Core instance.

func (*Core) GetProjectDir

func (c *Core) GetProjectDir(projectName string) common.Msg

Get the directory for the project with the given name.

func (*Core) GetProjectNames

func (c *Core) GetProjectNames() []string

Get all the names of the projects.

func (*Core) GetProjects

func (c *Core) GetProjects() (Projects, error)

Get the projects from the projects.json file.

func (*Core) GetProjectsConfig

func (c *Core) GetProjectsConfig() error

Get the projects from the projects.json file.

func (*Core) GetSigChan added in v0.7.2

func (c *Core) GetSigChan() *chan os.Signal

Get the signal channel of the Core instance.

func (*Core) Init

func (c *Core) Init() common.Msg

Initialize the config directory and files.

func (*Core) ProjectExists

func (c *Core) ProjectExists(name string) (bool, Project)

Check if a project with the given name exists. Returns the project if it exists.

func (*Core) RemoveCommand

func (c *Core) RemoveCommand(name string) common.Msg

Remove the command with the given name.

func (*Core) RemoveCommandFromProject

func (c *Core) RemoveCommandFromProject(projectName string, commandName string) common.Msg

Remove the command with the given commandName from the project with the given projectName.

func (*Core) RemoveDomainAlias added in v0.7.0

func (c *Core) RemoveDomainAlias(projectName string, domainAlias string) common.Msg

Remove a domain alias from the given project.

func (*Core) RemoveProject

func (c *Core) RemoveProject(name string) common.Msg

Remove the project with the given name.

func (*Core) RemoveVariable

func (c *Core) RemoveVariable(projectName string, key string) common.Msg

Remove the variable with the given key from the project with the given name.

func (*Core) RenameCommand added in v0.6.0

func (c *Core) RenameCommand(oldName string, newName string) common.Msg

Rename the command with the given old name to the given new name.

func (*Core) RenameProject added in v0.6.0

func (c *Core) RenameProject(oldName string, newName string) common.Msg

Rename the project with the given old name to the given new name.

func (*Core) RequireSudo

func (c *Core) RequireSudo() error

RequireSudo checks if the user has sudo permissions. This is needed to update some system files.

It returns an error if the user does not have sudo permissions.

func (*Core) SetErr added in v0.8.0

func (c *Core) SetErr(err io.Writer)

func (*Core) SetOut added in v0.8.0

func (c *Core) SetOut(out io.Writer)

func (*Core) SetProjectDir

func (c *Core) SetProjectDir(projectName string, dir *string) common.Msg

Set the directory for the project with the given name.

func (*Core) TryToRun

func (c *Core) TryToRun(name string) common.Msg

Try to run a project with the given name.

func (*Core) UpdateCommand added in v0.6.0

func (c *Core) UpdateCommand(name string, command string) common.Msg

Update the command with the given name to the given command string.

func (*Core) UpdateProject added in v0.6.0

func (c *Core) UpdateProject(name string, domain string, port int, commandNames []string) common.Msg

Update the project with the given name to the given domain, port and command names.

type DomainAliases added in v0.7.1

type DomainAliases []string

DomainAliases is a map of domain aliases to their domain names.

type Project

type Project struct {
	Domain        string        `json:"domain"`
	Port          int           `json:"port"`
	Commands      []string      `json:"commands"`
	Dir           *string       `json:"dir"`
	Variables     Variables     `json:"variables"`
	DomainAliases DomainAliases `json:"domainAliases"`
}

Project is a struct that represents a Project as stored in the projects.json file.

type Projects

type Projects map[string]Project

Projects is a map of project names to their Projects.

type Variables

type Variables map[string]string

Variables is a map of variable names to their values.

Jump to

Keyboard shortcuts

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