gencode

package
v0.0.0-...-705cc83 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package gencode generates code for toolskel. It's where everything happens.

Index

Constants

View Source
const DefaultTType = "simple"

DefaultTType is the default template to use.

Variables

This section is empty.

Functions

func Generate

func Generate(w io.Writer, tType string, data Data) error

Generate does the code generation itself.

func ListTypes

func ListTypes()

ListTypes prints template types as a table to stdout.

Types

type Data

type Data struct {
	/* Strings which go right into code. */
	Name         string              /* Package name. */
	Description  string              /* Short description. */
	Author       string              /* Author's name. */
	Today        string              /* Curent date. */
	SummaryCount bool                /* Print count with summary. */
	TagLog       bool                /* Tag logs with argv[0]. */
	PkgType      string              /* Package or Program (default)  */
	Verbose      bool                /* -verbose */
	Imports      map[string]struct{} /* Imported packages. */
}

Data is used to pass data to the template being executed.

func (Data) CmdDesc

func (d Data) CmdDesc() string

CmdDesc gets the command name and description, separated with a ": ".

func (Data) ImportsBlock

func (d Data) ImportsBlock() string

ImportsBlock returns a block of text suitable for use in an imports() block. Empty strings will be silently ignored.

func (*Data) SetDefaults

func (d *Data) SetDefaults()

SetDefaults makes sure every field of Data has a default value.

func (Data) WithImports

func (d Data) WithImports(imports ...string) Data

WithImports returns a copy of d with added imports.

func (Data) WithSet

func (d Data) WithSet(field string, val any) Data

WithSet returns a copy of d with the named field set to val. It panics if the field cannot be found or if val is not an appropriate type for the field.

Directories

Path Synopsis
Package main - A cool program
Package main - A cool program

Jump to

Keyboard shortcuts

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