build

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package build provides helpers for developing and building workflows.

Info provides Alfred and workflow settings, read from the environment, info.plist and Alfred's config files.

There are also utility functions to help build workflows:

Symlink()  // symlink files
Export()  // create an .alfredworkflow file from a directory

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(src, dest string) (path string, err error)

Export builds an .alfredworkflow file in directory dest from the files in directory src. If src is an empty string, "build" is used; if dest is empty, "dist" is used.

The filename of the workflow file is generated automatically from the workflow's info.plist and is returned if zipping succeeds.

func Symlink(link, target string, relative bool) error

Symlink creates a symlink to target.

func SymlinkGlobs

func SymlinkGlobs(destDir string, globs ...Glob) error

SymlinkGlobs symlinks multiple Globs to a directory.

Types

type Glob

type Glob struct {
	// Pattern is a glob-style pattern to match against filesystem
	Pattern string
	// DestDir is a relative directory within target directory
	// to where files matching Pattern should be linked.
	DestDir string
}

Glob is a pattern and (relative) destination directory.

func Globs

func Globs(pattern ...string) []Glob

Globs creates a slice of Globs for patterns.

type Info

type Info struct {
	// Workflow info read from environment variables/info.plist
	Name     string // Workflow name
	Version  string // Workflow version
	BundleID string // Workflow bundle ID

	// Workflow directories
	CacheDir string // Workflow cache directory
	DataDir  string // Workflow data directory
	// Where workflow should be installed. This is
	// Alfred's workflow directory (AlfredWorkflowDir)
	// plus workflow's bundle ID.
	InstallDir string

	// Alfred info
	AlfredMajorVersion int    // Alfred's major version number
	AlfredSyncDir      string // Path of Alfred's syncfolder
	AlfredPrefsBundle  string // Path to the Alfred.alfredpreferences bundle
	AlfredWorkflowDir  string // Directory workflows are stored in
	AlfredCacheDir     string // Root directory for all workflow cache data
	AlfredDataDir      string // Root directory for all persistent workflow data
	// contains filtered or unexported fields
}

Info contains information about a workflow and Alfred.

The information is extracted from environment variables, the workflow's info.plist, Alfred's own configuration files and finally, some defaults.

func NewInfo

func NewInfo(option ...Option) (*Info, error)

NewInfo creates a new Info. Workflow info is read from Alfred environment variables (if set), and from info.plist in the working directory and Alfred's configuration files. These paths may be changed using the the LibDir and InfoPlist Options. Settings from info.plist take priority over those from environment variables.

It returns an error if info.plist or the configuration files cannot be found.

func (*Info) Env

func (info *Info) Env() map[string]string

Env returns an Alfred-like environment.

type Option

type Option func(info *Info)

Option configures Info created by New.

func InfoPlist

func InfoPlist(path string) Option

InfoPlist tells New to parse a specific info.plist file. Default is ./info.plist.

func LibDir

func LibDir(dir string) Option

LibDir tells New to search a specific directory for Alfred config files. Default is ~/Library.

Jump to

Keyboard shortcuts

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