inst

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: MIT Imports: 10 Imported by: 0

README

inst

file install package

Installation

$ go get github.com/gnue/inst

Usage

import "github.com/gnue/inst"

Examples

Install
//var templ = template.Must(template.New("config").Parse("name: {{.Name}}\n"))
var Pkg = &inst.Pkg{
    //Template:        templ,
    Template:        &Template{},
    Locals:          []string{"$XDG_CONFIG_HOME", "$HOME/.config"},
    Globals:         []string{"/usr/local/etc"},
    InstallAction:   nil,
    UninstallAction: nil,
}

type Config struct {
    Name string
}

Pkg.Install("config.txt", 0644, &Config{Name: "Alice"}, inst.Local, false)

install file

Uninstall
package main

import (
	"github.com/gnue/inst"
)

func main() {
	var Pkg = &inst.Pkg{
		Locals:  []string{"$XDG_CONFIG_HOME", "$HOME/.config"},
		Globals: []string{"/usr/local/etc"},
	}

	Pkg.Uninstall("config.txt", inst.Local)
}

uninstall file

Author

gnue

License

MIT

Documentation

Overview

file install package

Index

Constants

View Source
const (
	Local = Locate(iota)
	Global
)

Variables

View Source
var (
	ErrNoInstallPath = errors.New("no install path")
)

Functions

func EmptyEnvs

func EmptyEnvs(a []string) []string

func EmptyVars

func EmptyVars(s string) []string

func FindDir

func FindDir(dirs []string, mkdir bool) string

func Vars

func Vars(s string) []string

Types

type Locate

type Locate int

type PathError

type PathError struct {
	Op   string
	Path string
	Err  error
}

func (*PathError) Error

func (e *PathError) Error() string

type Pkg

type Pkg struct {
	Template        Template
	Locals          []string
	Globals         []string
	InstallAction   func(fname string, loc Locate) error
	UninstallAction func(fname string, loc Locate) error
}

func New

func New(t Template, dirs ...string) *Pkg

func (*Pkg) Create

func (pkg *Pkg) Create(fname string, mode os.FileMode, data interface{}) (err error)

func (*Pkg) Install

func (pkg *Pkg) Install(name string, mode os.FileMode, data interface{}, loc Locate, force bool) (fname string, err error)

func (*Pkg) InstallPath

func (pkg *Pkg) InstallPath(loc Locate, mkdir bool) (string, error)

func (*Pkg) Uninstall

func (pkg *Pkg) Uninstall(name string, loc Locate) (fname string, err error)

type Template

type Template interface {
	Execute(wr io.Writer, data interface{}) error
}

Directories

Path Synopsis
pkgs
bash-completion
bash-completion install package * for use "github.com/jessevdk/go-flags" CLI * install path * $BASH_COMPLETION_DIR (local) * $BASH_COMPLETION_COMPAT_DIR (global)
bash-completion install package * for use "github.com/jessevdk/go-flags" CLI * install path * $BASH_COMPLETION_DIR (local) * $BASH_COMPLETION_COMPAT_DIR (global)
copy
file copy install package * use http.FileSystem interface
file copy install package * use http.FileSystem interface
launchagent
launchagent install package for macOS * install path * $HOME/Library/LaunchAgents (local) * /Library/LaunchAgents (global)
launchagent install package for macOS * install path * $HOME/Library/LaunchAgents (local) * /Library/LaunchAgents (global)
launchdaemon
launchdaemon install package for macOS * install path * $HOME/Library/LaunchAgents (local) * /Library/LaunchDaemons (global)
launchdaemon install package for macOS * install path * $HOME/Library/LaunchAgents (local) * /Library/LaunchDaemons (global)

Jump to

Keyboard shortcuts

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