Documentation ¶
Index ¶
- Constants
- Variables
- func DoWatch(F func(fast bool) (chan bool, error), dofast, onfirst bool, files []string, ...) error
- func Gen(args []string, rootflags flags.RootPflagpole, cmdflags flags.GenFlagpole) error
- func InitModule(args []string, rootflags flags.RootPflagpole, cmdflags flags.GenFlagpole) error
- func LoadShadow(basedir string, verbosity int) (map[string]*File, error)
- func NewDebouncer(after time.Duration) func(f func())
- type AdhocTemplateConfig
- type File
- func (F *File) FormatRendered() (err error)
- func (F *File) ReadUser(outdir string) error
- func (F *File) Render(outdir string, UseDiff3 bool) error
- func (F *File) RenderData() (err error)
- func (F *File) RenderTemplate() (err error)
- func (F *File) UnifyContent(UseDiff3 bool) (write bool, err error)
- func (F *File) WriteOutput(basedir string) error
- func (F *File) WriteShadow(basedir string) error
- type FileStats
- type FmtConfig
- type Generator
- func (G *Generator) CleanupRemainingShadow(outputDir, shadowDir string, verbosity int) (errs []error)
- func (G *Generator) DecodeFromCUE() (errs []error)
- func (G *Generator) GenerateFiles(outdir string) []error
- func (G *Generator) Initialize() []error
- func (G *Generator) NamePath() string
- func (G *Generator) OutputPath() string
- func (G *Generator) ResolveFile(F *File) error
- func (G *Generator) ShadowPath() string
- type GeneratorStats
- type Runtime
- func (R *Runtime) AsModule() error
- func (R *Runtime) CleanupGeneratorShadow(G *Generator) (errs []error)
- func (R *Runtime) CleanupRemainingShadow() (errs []error)
- func (R *Runtime) ClearGenerators()
- func (R *Runtime) CreateAdhocGenerator() error
- func (R *Runtime) ExtractGenerators() error
- func (R *Runtime) ListGenerators() (gens []string, err error)
- func (R *Runtime) LoadCue() (err error)
- func (R *Runtime) LoadGenerators() []error
- func (R *Runtime) OutputDir() string
- func (R *Runtime) PrintMergeConflicts()
- func (R *Runtime) PrintStats()
- func (R *Runtime) Reload(fast bool) error
- func (R *Runtime) RunGenerator(G *Generator) (errs []error)
- func (R *Runtime) RunGenerators() []error
- func (R *Runtime) ShadowDir() string
- func (R *Runtime) WriteGenerator(G *Generator) (errs []error)
- func (R *Runtime) WriteOutput() []error
- type RuntimeStats
- type StaticGlobs
- type TemplateContent
- type TemplateGlobs
Constants ¶
const CUE_VENDOR_DIR = "cue.mod/pkg"
const SHADOW_DIR = ".hof/shadow/"
Variables ¶
var FORMAT_DISABLED = false
Functions ¶
func Gen ¶ added in v0.6.0
func Gen(args []string, rootflags flags.RootPflagpole, cmdflags flags.GenFlagpole) error
func InitModule ¶ added in v0.6.3
func InitModule(args []string, rootflags flags.RootPflagpole, cmdflags flags.GenFlagpole) error
func NewDebouncer ¶ added in v0.6.3
Types ¶
type AdhocTemplateConfig ¶ added in v0.6.3
type AdhocTemplateConfig struct { // Template filepath Filepath string // CUE path to input value within global value Cuepath string // CUE path to schema value within global value Schema string // Filepath to write results, possibly templated Outpath string // Is this a repeated template Repeated bool }
parsed version of the --template flag semicolon separated: <filepath>:<?cuepath>@<schema>;[]<?outpath> each extra section is
type File ¶
type File struct { // Input Data, local to this file In interface{} // The full path under the output location // empty implies don't generate, even though it may endup in the list Filepath string // Template parameters (only one should be set at a time i.e. != "") TemplateContent string // The content, takes precedence over next option TemplatePath string // Named template DatafileFormat string // Data format file StaticFile bool // Formatting FormattingDisabled bool FormattingConfig *FmtConfig // Template delimiters TemplateDelims *templates.Delims // CUE value for datafiles // (we use a different name here so that it does not automatically try to decode, which would require concreteness) Value cue.Value // Template Instance Pointer // If local, this will be created when the template content is laoded // If a named template, acutal template lives in the generator and is created at folder import time TemplateInstance *templates.Template // Content RenderContent []byte FinalContent []byte // Shadow related ShadowFile *File UserFile *File DoWrite bool // Bookkeeping Errors []error FileStats // contains filtered or unexported fields }
func (*File) FormatRendered ¶
func (*File) RenderData ¶ added in v0.6.1
func (*File) RenderTemplate ¶
func (*File) WriteOutput ¶
func (*File) WriteShadow ¶
type FileStats ¶
type FileStats struct { // using 0 (false) and 1 (true) for easier summation code below IsNew int IsSame int IsSkipped int IsWritten int IsErr int IsModified int IsModifiedRender int IsModifiedOutput int IsModifiedDiff3 int IsConflicted int RenderingTime time.Duration CompareTime time.Duration TotalTime time.Duration }
type Generator ¶
type Generator struct { // // Set by Hof via cuelang extraction // Label in Cuelang Name string // Base directory for output Outdir string // Other important dirs when loading templates (auto set) CueModuleRoot string WorkingDir string // "Global" input, merged with out replacing onto the files In map[string]interface{} Val cue.Value // File globs to watch and trigger regen on change WatchFull []string WatchFast []string // Formatting FormattingDisabled bool FormatData bool FormattingConfigs map[string]FmtConfig // The list fo files for hof to generate, in cue values Out []*File Templates []*TemplateGlobs Partials []*TemplateGlobs // Filepath globs for static files to load Statics []*StaticGlobs // The following will be automatically added to the template context // under its name for reference in GenFiles and partials in templates EmbeddedTemplates map[string]*TemplateContent EmbeddedPartials map[string]*TemplateContent // Static files are available for pure cue generators that want to have static files // These should be named by their filepath, but be the content of the file EmbeddedStatics map[string]string // Subgenerators for composition Generators map[string]*Generator // Used for indexing into the vendor directory... PackageName string // Use Diff3 & Shadow UseDiff3 bool // Disabled? we do this when looking at expressions and optimizing // TODO, make this field available in cuelang? Disabled bool // Template System Cache TemplateMap templates.TemplateMap PartialsMap templates.TemplateMap // Files and the shadow dir for doing neat things OrderedFiles []*File Files map[string]*File Shadow map[string]*File // Print extra information Debug bool // Status for this generator and processing Stats *GeneratorStats // Cuelang related, also set externally CueValue cue.Value // contains filtered or unexported fields }
A generator pulled from the cue instances
func (*Generator) CleanupRemainingShadow ¶ added in v0.6.5
func (*Generator) DecodeFromCUE ¶ added in v0.6.5
func (*Generator) GenerateFiles ¶
func (*Generator) Initialize ¶ added in v0.2.9
func (*Generator) NamePath ¶ added in v0.6.5
Returns Generators name path, including parents as a path like string
func (*Generator) OutputPath ¶ added in v0.6.5
Returns Generators contribution to the output path, including parents contributions if a subgen. Each gen in the path is [parent]/G.Outdir
func (*Generator) ResolveFile ¶ added in v0.2.9
func (*Generator) ShadowPath ¶ added in v0.6.5
Returns Generators contribution to the shadow path, including parents contributions if a subgen. Each gen in the path is [parent]/G.Name/G.Outdir
type GeneratorStats ¶
type GeneratorStats struct { NumNew int NumSame int NumSkipped int NumDeleted int NumWritten int NumStatic int NumErr int TotalFiles int NumModified int NumModifiedRender int NumModifiedOutput int NumModifiedDiff3 int NumConflicted int LoadingTime time.Duration RenderingTime time.Duration WritingTime time.Duration TotalTime time.Duration }
func (*GeneratorStats) CalcTotals ¶
func (S *GeneratorStats) CalcTotals(G *Generator) error
func (*GeneratorStats) String ¶
func (S *GeneratorStats) String() string
type Runtime ¶ added in v0.6.0
type Runtime struct { sync.Mutex // Setup options Entrypoints []string Flagpole flags.GenFlagpole Verbosity int // Cue ralated CueRuntime *cuetils.CueRuntime CueModuleRoot string WorkingDir string // Hof related Generators map[string]*Generator Stats *RuntimeStats // contains filtered or unexported fields }
func NewRuntime ¶ added in v0.6.0
func NewRuntime(entrypoints []string, cmdflags flags.GenFlagpole) *Runtime
func (*Runtime) CleanupGeneratorShadow ¶ added in v0.6.5
func (*Runtime) CleanupRemainingShadow ¶ added in v0.6.5
func (*Runtime) ClearGenerators ¶ added in v0.6.3
func (R *Runtime) ClearGenerators()
func (*Runtime) CreateAdhocGenerator ¶ added in v0.6.3
func (*Runtime) ExtractGenerators ¶ added in v0.6.0
func (*Runtime) ListGenerators ¶ added in v0.6.3
func (*Runtime) LoadGenerators ¶ added in v0.6.0
func (*Runtime) OutputDir ¶ added in v0.6.5
OutputDir returns the absolute path to output dir for this runtime. Generators will make subdir contributions at read/write time
func (*Runtime) PrintMergeConflicts ¶ added in v0.6.0
func (R *Runtime) PrintMergeConflicts()
func (*Runtime) PrintStats ¶ added in v0.6.0
func (R *Runtime) PrintStats()
func (*Runtime) Reload ¶ added in v0.6.3
Clears and reloads a runtime, rereading inputs and reprocessing everything fast determines if the CUE code is reloaded and evaluated or not (fast is not). These modes correspond to the -W (full) and -X (fast) watch flags
func (*Runtime) RunGenerator ¶ added in v0.6.0
func (*Runtime) RunGenerators ¶ added in v0.6.0
func (*Runtime) ShadowDir ¶ added in v0.6.5
ShadowDir returns the absolute path to shadow dir for this runtime. Generators will make subdir contributions at read/write time
func (*Runtime) WriteGenerator ¶ added in v0.6.0
func (*Runtime) WriteOutput ¶ added in v0.6.0
type RuntimeStats ¶ added in v0.6.1
type RuntimeStats struct { CueLoadingTime time.Duration GenLoadingTime time.Duration GenRunningTime time.Duration }
func (*RuntimeStats) String ¶ added in v0.6.1
func (S *RuntimeStats) String() string