emb

package module
v0.0.0-...-d8f499a Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

README

🌳 Go Bonzai™ Embedded Files and Directories

Embed and transport files within your Bonzai stateful command trees.

go install ./cmd/embsample
complete -C embsample embsample
embsample <TAB><TAB>
embsample cat <TAB><TAB>
embsample cat some.txt
embsample cat '*.md'

See the Bonzai Book for more.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FS  embed.FS // assigned
	Top string   // path to top directory (ex: files)
)

set from init by importers, but also changeable at runtime

View Source
var Cmd = &Z.Cmd{

	Name:      `emb`,
	Summary:   `access embedded files`,
	Version:   `v0.0.1`,
	Copyright: `Copyright 2021 Robert S Muhlestein`,
	License:   `Apache-2.0`,
	Source:    `git@github.com:rwxrob/emb.git`,
	Issues:    `github.com/rwxrob/emb/issues`,

	Init: func(x *Z.Cmd, args ...string) error {
		var zero embed.FS
		switch {
		case FS == zero:
			return MissingFS{}
		case Top == "":
			return MissingTop{}
		}
		return nil
	},

	Commands: []*Z.Cmd{help.Cmd, catCmd, listCmd},

	Dynamic: template.FuncMap{
		`list`: func() string { return strings.Join(RelPaths(), "\n") },
	},

	Description: `
		The **{{.Name}}** command provides access to files embedded within
		this binary:

		  {{ list }}

		`,
}

Functions

func Cat

func Cat(globs ...string) ([]byte, error)

func RelPaths

func RelPaths() []string

Types

type MissingFS

type MissingFS struct{}

func (MissingFS) Error

func (e MissingFS) Error() string

type MissingTop

type MissingTop struct{}

func (MissingTop) Error

func (e MissingTop) Error() string

Directories

Path Synopsis
cmd
embsample command

Jump to

Keyboard shortcuts

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