cli

package
v0.1.16 Latest Latest
Warning

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

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

Documentation

Overview

Package cli provides command-line interface tools for GoSPA.

Package cli provides the state pruning functionality for GoSPA.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(config *BuildConfig)

Build builds the application for production.

func BuildAll

func BuildAll()

BuildAll builds for all platforms.

func BuildWithConfig

func BuildWithConfig(config *BuildConfig) error

BuildWithConfig builds the application with custom configuration.

func Clean

func Clean()

Clean removes build artifacts.

func CreateProject

func CreateProject(name string)

CreateProject creates a new GoSPA project with the given name.

func CreateProjectWithConfig

func CreateProjectWithConfig(config *ProjectConfig) error

CreateProjectWithConfig creates a new GoSPA project with custom configuration.

func Dev

func Dev(config *DevConfig)

Dev starts the development server with hot reload.

func DevWithConfig

func DevWithConfig(config *DevConfig) error

DevWithConfig starts the development server with custom configuration.

func Generate

func Generate(config *GenerateConfig)

Generate generates TypeScript types and routes from Go templates.

func GenerateWithConfig

func GenerateWithConfig(config *GenerateConfig) error

GenerateWithConfig generates code with custom configuration.

func PrintBanner

func PrintBanner()

PrintBanner prints the GoSPA banner

func Prune

func Prune(config *PruneConfig)

Prune executes the state pruning command.

func StateAnalyze

func StateAnalyze(config *PruneConfig)

StateAnalyze executes the state analysis command.

func StateTree

func StateTree(stateFile string, usedPaths []string, jsonOut bool)

StateTree executes the state tree visualization command.

func ValidateProjectName

func ValidateProjectName(name string) error

ValidateProjectName checks if a project name is valid.

func Watch

func Watch()

Watch builds and watches for changes.

Types

type BuildConfig

type BuildConfig struct {
	OutputDir    string
	Platform     string
	Arch         string
	StaticAssets bool
	Minify       bool
	Compress     bool
	Env          string
}

BuildConfig holds configuration for the production build.

type ColorPrinter

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

ColorPrinter provides colored output utilities

func NewColorPrinter

func NewColorPrinter() *ColorPrinter

NewColorPrinter creates a new color printer

func (*ColorPrinter) Bold

func (p *ColorPrinter) Bold(text string) string

Bold returns bold text

func (*ColorPrinter) Cyan

func (p *ColorPrinter) Cyan(text string) string

Cyan returns cyan text

func (*ColorPrinter) Dim

func (p *ColorPrinter) Dim(text string) string

Dim returns dimmed text

func (*ColorPrinter) Error

func (p *ColorPrinter) Error(format string, args ...interface{})

Error prints a red error message with X mark

func (*ColorPrinter) Green

func (p *ColorPrinter) Green(text string) string

Green returns green text

func (*ColorPrinter) Info

func (p *ColorPrinter) Info(format string, args ...interface{})

Info prints a blue info message

func (*ColorPrinter) ProgressBar

func (p *ColorPrinter) ProgressBar(current, total int, label string)

ProgressBar displays a simple progress bar

func (*ColorPrinter) Red

func (p *ColorPrinter) Red(text string) string

Red returns red text

func (*ColorPrinter) Step

func (p *ColorPrinter) Step(step int, total int, format string, args ...interface{})

Step prints a step in a process

func (*ColorPrinter) Subtitle

func (p *ColorPrinter) Subtitle(format string, args ...interface{})

Subtitle prints a dimmed subtitle

func (*ColorPrinter) Success

func (p *ColorPrinter) Success(format string, args ...interface{})

Success prints a green success message with checkmark

func (*ColorPrinter) Title

func (p *ColorPrinter) Title(format string, args ...interface{})

Title prints a bold title

func (*ColorPrinter) Warning

func (p *ColorPrinter) Warning(format string, args ...interface{})

Warning prints a yellow warning message

func (*ColorPrinter) Yellow

func (p *ColorPrinter) Yellow(text string) string

Yellow returns yellow text

type DevConfig

type DevConfig struct {
	Port          int
	Host          string
	RoutesDir     string
	ComponentsDir string
	WatchPaths    []string
	IgnorePaths   []string
	Debounce      time.Duration
}

DevConfig holds configuration for the development server.

type DevServer

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

DevServer represents the development server.

func NewDevServer

func NewDevServer(config *DevConfig) *DevServer

NewDevServer creates a new development server.

func (*DevServer) Broadcast

func (s *DevServer) Broadcast(reload HotReload)

Broadcast sends a reload event to all connected clients.

func (*DevServer) Start

func (s *DevServer) Start() error

Start starts the development server.

func (*DevServer) Stop

func (s *DevServer) Stop()

Stop stops the development server.

type DevWatcher

type DevWatcher struct {
	Events chan FileEvent
	Errors chan error
	// contains filtered or unexported fields
}

DevWatcher watches files for changes.

func NewDevWatcher

func NewDevWatcher(dirs ...string) *DevWatcher

NewDevWatcher creates a new file watcher.

func (*DevWatcher) Start

func (w *DevWatcher) Start() error

Start starts the file watcher.

func (*DevWatcher) Stop

func (w *DevWatcher) Stop()

Stop stops the file watcher.

type FileEvent

type FileEvent struct {
	File    string
	Op      FileOp
	ModTime time.Time
}

FileEvent represents a file change event.

type FileOp

type FileOp int

FileOp represents the type of file operation.

const (
	FileOpCreate FileOp = iota
	FileOpModify
	FileOpDelete
	FileOpRename
)

type GenerateConfig

type GenerateConfig struct {
	InputDir   string
	OutputDir  string
	StateFiles []string
	RouteFiles []string
}

GenerateConfig holds configuration for code generation.

type HotReload

type HotReload struct {
	Type    string `json:"type"`
	File    string `json:"file"`
	Message string `json:"message"`
}

HotReload represents a hot reload event.

type ProjectConfig

type ProjectConfig struct {
	Name       string
	Module     string
	OutputDir  string
	WithGit    bool
	WithDocker bool
}

ProjectConfig holds configuration for a new GoSPA project.

type PruneConfig

type PruneConfig struct {
	RootDir    string
	OutputDir  string
	ReportFile string
	KeepUnused bool
	Aggressive bool
	Exclude    []string
	Include    []string
	DryRun     bool
	Verbose    bool
	JSONOutput bool
}

PruneConfig holds configuration for the prune command.

type RouteDefinition

type RouteDefinition struct {
	Path       string
	File       string
	Params     []string
	IsDynamic  bool
	IsCatchAll bool
}

RouteDefinition represents a route definition.

type Spinner

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

Spinner shows a spinning animation

func NewSpinner

func NewSpinner(printer *ColorPrinter, message string) *Spinner

NewSpinner creates a new spinner

func (*Spinner) Done

func (s *Spinner) Done()

Done stops the spinner with success

func (*Spinner) Fail

func (s *Spinner) Fail()

Fail stops the spinner with failure

func (*Spinner) Tick

func (s *Spinner) Tick()

Tick advances the spinner

type TypeScriptField

type TypeScriptField struct {
	Name     string
	Type     string
	Optional bool
}

TypeScriptField represents a field in a TypeScript type.

type TypeScriptType

type TypeScriptType struct {
	Name   string
	Fields []TypeScriptField
}

TypeScriptType represents a TypeScript type definition.

Jump to

Keyboard shortcuts

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