Documentation
¶
Overview ¶
Package initpkg implements `llcppg -init`, which bootstraps a new binding repository from the llcppg template. See the package-level Init function for the full behavior.
Index ¶
Constants ¶
View Source
const ( // DefaultTemplateURL is the git URL of the llcppg project template. DefaultTemplateURL = "https://github.com/llarhub/.llcppg" // Placeholder is the token substituted with the module name in the files // listed by substituteFiles. Placeholder = "MODULE_NAME" )
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init bootstraps a new binding repository from the template, in the current repository rooted at dir. It:
- determines the module name (the given module, or the current directory's name when module is empty) and validates the environment (dir is a git repo, no existing c branch, no existing go.mod);
- prepares the template in the cache (clone on first use, update otherwise, falling back to the cached copy when offline);
- creates and commits a c branch with the template's c-branch files, with MODULE_NAME substituted in c/go.mod and c/llcppg.cfg;
- switches to the main branch (creating it only if it does not already exist) and commits the template's main-branch files, with MODULE_NAME substituted in go.mod and the standard badges inserted into README.md;
- leaves main checked out and reports what was done.
It never pushes, adds or modifies remotes, or changes git configuration.
Types ¶
type Config ¶
type Config struct {
// TemplateURL is the git URL of the template repository. Empty means
// DefaultTemplateURL.
TemplateURL string
// CacheDir is the directory that holds the cached template clone. required.
CacheDir string
// Stdout receives the human-readable progress and completion report. Empty
// means os.Stdout.
Stdout io.Writer
// Stderr receives warnings (for example, the offline fallback notice).
// Empty means os.Stderr.
Stderr io.Writer
}
Config configures Init. The zero value uses the public template and the per-user cache directory; tests and advanced callers can override both.
Click to show internal directories.
Click to hide internal directories.