hof

module
v0.5.17 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: BSD-3-Clause

README

hof - the high code framework

The hof tool tries to remove redundent development activities by using high level designs, code generation, and diff3 while letting you write custom code directly in the output. ( low-code for developers )

  • Users write Single Source of Truth (SSoT) design for data models and the application generators
  • hof reads the SSoT, processes it through the code generators, and outputs directories and files
  • Users can write custom code in the output, change their designs, and regenerate code in any order
  • hof can be customized and extended by only editing text files and not hof source code.
  • Use your own tools, technologies, and practices, hof does not make any choices for you
  • hof is powered by Cue (https://cuelang.org & https://cuetorials.com)

Install

You will have to download hof the first time. After that hof will prompt you to update and install new releases as they become available.

# Install (Linux, Mac, Windows)
curl -LO https://github.com/hofstadter-io/hof/releases/download/v0.5.15/hof_0.5.15_$(uname)_$(uname -m)
mv hof_0.5.15_$(uname)_$(uname -m) /usr/local/bin/hof

# Shell Completions (bash, zsh, fish, power-shell)
echo ". <(hof completion bash)" >> $HOME/.profile
source $HOME/.profile

# Show the help text
hof --help

You can always find the latest version from the releases page or use hof to install a specific version of itself with hof update --version vX.Y.Z.

Documentation

Please see https://docs.hofstadter.io to learn more.

Join us on Slack! https://hofstadter-io.slack.com (invite link)

Example

There are currently hof modules for:

  • hofmod-cli - CLI infrastructure based on the Golang Cobra library.
  • hofmod-server - API server based on the Golang Echo library.

You can see them used in:

  • hof uses hofmod-cli
  • saas uses hofmod-server

The following is a single file example:

package gen

import (
	// import hof's schemas for our generator
	"github.com/hofstadter-io/hof/schema"
)

// A schema for our generator's input
#Input: {
	name: string
	todos: [...{
		name: string
		effort: int
		complete: bool
	}]
}
// create a generator
#Gen: schema.#HofGenerator & {
	// We often have some input values for the user to provide.
	// Use a Cue definition to enforce a schema
	Input: #Input

	// Required filed for generator definitions, details can be found in the hof docs
	PackageName: "dummy"

	// Required field for a generator to work, the list of files to generate
	Out: [...schema.#HofGeneratorFile] & [
		todo,
		done,
		debug,
	]

	// In is supplied as the root data object to every template
	// pass user inputs to the tempaltes here, possibly modified, enhanced, or transformed
	In: {
		INPUT: Input
		Completed: _C
		Incomplete: _I
	}

	// calculate some internal data from the input
	_C: [ for t in Input.todos if t.complete == true { t } ]
	_I: [ for t in Input.todos if t.complete == false { t } ]

	// the template files
	todo: {
		Template: """
		Hello {{ .INPUT.name }}.

		The items still on your todo list:

		{{ range $T := .Incomplete -}}
		{{ printf "%-4s%v" $T.name $T.effort }}
		{{ end }}
		"""
		// The output filename, using string interpolation
		Filepath: "\(Input.name)-todo.txt"
	}
	done: {
		Template: """
		Here's what you have finished {{ .INPUT.name }}. Good job!

		{{ range $T := .Completed -}}
		{{ $T.name }}
		{{ end }}
		"""
		Filepath: "\(Input.name)-done.txt"
	}

	// useful helper
	debug: {
		Template: """
		{{ yaml . }}
		"""
		Filepath: "debug.yaml"
	}
}

// Add the @gen(<name>,<name>,...) to denote usage of a generator
Gen: _ @gen(todos)
// Construct the generator
Gen: #Gen & {
	Input: {
		// from first.cue
		name: gen.data.name
		todos: gen.data.tasks
	}
}

Directories

Path Synopsis
cmd
hof
gen
lib
connector
Package connector ...
Package connector ...
datamodel
package datamodel - for modeling and managing that model
package datamodel - for modeling and managing that model
gen
gotils/cache
Package cache implements a build artifact cache.
Package cache implements a build artifact cache.
gotils/cmd/txtar-addmod
The txtar-addmod command adds a module as a txtar archive to the a testdata module directory as understood by the goproxytest package (see https://godoc.org/github.com/hofstadter-io/hof/lib/gotils/goproxytest).
The txtar-addmod command adds a module as a txtar archive to the a testdata module directory as understood by the goproxytest package (see https://godoc.org/github.com/hofstadter-io/hof/lib/gotils/goproxytest).
gotils/cmd/txtar-c
The txtar-c command archives a directory tree as a txtar archive printed to standard output.
The txtar-c command archives a directory tree as a txtar archive printed to standard output.
gotils/cmd/txtar-goproxy
The txtar-goproxy command runs a Go module proxy from a txtar module directory (as manipulated by the txtar-addmod command).
The txtar-goproxy command runs a Go module proxy from a txtar module directory (as manipulated by the txtar-addmod command).
gotils/cmd/txtar-x
The txtar-x command extracts a txtar archive to a filesystem.
The txtar-x command extracts a txtar archive to a filesystem.
gotils/dirhash
Package dirhash defines hashes over directory trees.
Package dirhash defines hashes over directory trees.
gotils/fmtsort
Package fmtsort provides a general stable ordering mechanism for maps, on behalf of the fmt and text/template packages.
Package fmtsort provides a general stable ordering mechanism for maps, on behalf of the fmt and text/template packages.
gotils/goproxytest
Package goproxytest serves Go modules from a proxy server designed to run on localhost during tests, both to make tests avoid requiring specific network servers and also to make them significantly faster.
Package goproxytest serves Go modules from a proxy server designed to run on localhost during tests, both to make tests avoid requiring specific network servers and also to make them significantly faster.
gotils/gotooltest
Package gotooltest implements functionality useful for testing tools that use the go command.
Package gotooltest implements functionality useful for testing tools that use the go command.
gotils/intern/syscall/windows/sysdll
Package sysdll is an internal leaf package that records and reports which Windows DLL names are used by Go itself.
Package sysdll is an internal leaf package that records and reports which Windows DLL names are used by Go itself.
gotils/intern/textutil
package textutil contains text processing utilities.
package textutil contains text processing utilities.
gotils/lockedfile
Package lockedfile creates and manipulates files whose contents should only change atomically.
Package lockedfile creates and manipulates files whose contents should only change atomically.
gotils/lockedfile/internal/filelock
Package filelock provides a platform-independent API for advisory file locking.
Package filelock provides a platform-independent API for advisory file locking.
gotils/modfile
Package modfile implements parsing and formatting for go.mod files.
Package modfile implements parsing and formatting for go.mod files.
gotils/module
Package module defines the module.Version type along with support code.
Package module defines the module.Version type along with support code.
gotils/par
Package par implements parallel execution helpers.
Package par implements parallel execution helpers.
gotils/renameio
Package renameio writes files atomically by renaming temporary files.
Package renameio writes files atomically by renaming temporary files.
gotils/semver
Package semver implements comparison of semantic version strings.
Package semver implements comparison of semantic version strings.
gotils/testenv
Package testenv provides information about what functionality is available in different testing environments run by the Go team.
Package testenv provides information about what functionality is available in different testing environments run by the Go team.
gotils/txtar
Package txtar implements a trivial text-based file archive format.
Package txtar implements a trivial text-based file archive format.
labels
Should be able to query select by labels and then apply one more more lables So basically "Get" with label changes, will need to expand to some CRUD ops almost their own thing, but want some real flexibility here
Should be able to query select by labels and then apply one more more lables So basically "Get" with label changes, will need to expand to some CRUD ops almost their own thing, but want some real flexibility here
mod
mod/parse/lazyregexp
Package lazyregexp is a thin wrapper over regexp, allowing the use of global regexp variables without forcing them to be compiled at init.
Package lazyregexp is a thin wrapper over regexp, allowing the use of global regexp variables without forcing them to be compiled at init.
ops
resources
package resources - for working with hof stuff and crds Resources are a conceptualization around things and bringing some consistency in how difinitions are written.
package resources - for working with hof stuff and crds Resources are a conceptualization around things and bringing some consistency in how difinitions are written.
yagu/configdir
Package configdir provides a cross platform means of detecting the system's configuration directories.
Package configdir provides a cross platform means of detecting the system's configuration directories.
yagu/par
Package par implements parallel execution helpers.
Package par implements parallel execution helpers.
Package testscript provides support for defining filesystem-based tests by creating scripts in a directory.
Package testscript provides support for defining filesystem-based tests by creating scripts in a directory.
shell
Package ishell implements an interactive shell.
Package ishell implements an interactive shell.

Jump to

Keyboard shortcuts

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