Documentation
¶
Index ¶
- func Create(opts Options, report Reporter) error
- func ParseGitProgress(line string) (string, float64, bool)
- func Project(name, mod string, layout *TemplateLayout) error
- func ValidateProjectName(name string) error
- type LayoutItem
- type LayoutLock
- type Options
- type ProgressEvent
- type Reporter
- type TemplateLayout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create runs the full project creation pipeline, reporting progress through the optional reporter.
func ParseGitProgress ¶
ParseGitProgress extracts a phase name and normalized 0..1 progress from a git clone progress line such as "Receiving objects: 45% (123/273)". Cloning weighs 2%, receiving 83%, resolving deltas 10%, and updating files the remaining 5%.
func Project ¶
func Project(name, mod string, layout *TemplateLayout) error
Project creates a project with default options: git init and dependency installation enabled. It is kept for scripted usage and tests.
func ValidateProjectName ¶
ValidateProjectName rejects names that would create the project outside the current directory or silently produce a different directory than the name the user typed (path separators, "." / ".." traversal, stray whitespace).
Types ¶
type LayoutItem ¶
type LayoutItem struct {
Name string `json:"name"`
Path string `json:"path"`
Description string `json:"description"`
}
func BuiltInLayouts ¶
func BuiltInLayouts() []*LayoutItem
BuiltInLayouts returns the layouts compiled into the CLI. The interactive wizard falls back to this list when the remote layout list is unreachable.
func LayoutList ¶
func LayoutList() ([]*LayoutItem, error)
func LayoutListWithFallback ¶
func LayoutListWithFallback() ([]*LayoutItem, bool, error)
LayoutListWithFallback returns the remote layout list, falling back to the built-in layouts when the remote list is unreachable. The second result reports whether the remote list was used.
type LayoutLock ¶
type Options ¶
type Options struct {
Name string
Module string
Layout *TemplateLayout
InitGit bool
InitDeps bool
}
Options describes a project creation run. Name and Module are required, Layout may be nil to select the default layout, and the boolean switches control the optional post-scaffold steps.
type ProgressEvent ¶
type ProgressEvent struct {
// Step is the zero-based index of the current pipeline step.
Step int
// TotalSteps is the number of steps in the pipeline.
TotalSteps int
// Label is a human-readable description of the current step.
Label string
// Percent is the progress inside the current step, 0..1. Negative values
// mean the step has no measurable progress (spinner only).
Percent float64
// Detail is the most recent command or status line of the current step.
Detail string
// Done marks the whole pipeline as finished.
Done bool
}
ProgressEvent reports what the creation pipeline is currently doing. The interactive UI renders it as an overall progress bar; the CLI prints it as plain log lines.
type Reporter ¶
type Reporter func(ProgressEvent)
Reporter receives progress events; it must be safe for concurrent use.
type TemplateLayout ¶
type TemplateLayout struct {
Name string `json:"name,omitempty"`
Source string `json:"source,omitempty"`
Ref string `json:"ref,omitempty"`
URI string `json:"uri,omitempty"`
Mod string `json:"mod,omitempty"`
Path string `json:"path,omitempty"`
}
func Layout ¶
func Layout(nameOrUri string) (*TemplateLayout, error)