pkg

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DryRun mode
	DryRun bool

	// Upgrade pacakges
	Upgrade bool

	// ErrExist ...
	ErrExist = fmt.Errorf("package already present")

	// Stdout writer
	Stdout io.Writer = os.Stdout
	// Stderr writer
	Stderr io.Writer = os.Stderr
	// Stdin reader
	Stdin io.Reader = os.Stdin
)

Functions

func Detect

func Detect() (name string, err error)

Detect default package manager

func Has

func Has(manager string, pkgs []string, opts ...string) (bool, error)

Has package

func Init

func Init(manager string) error

Init manager only before install

func Install

func Install(manager string, pkgs []string, opts ...string) error

Install package

func Remove

func Remove(manager string, pkgs []string, opts ...string) error

Remove package

Types

type Pm

type Pm struct {
	Shell       string
	Sudo        bool        // Prefix Bin with sudo if not root
	Bin         string      // Path to package manager binary
	Sub         []string    // Sub command and main options
	Install     interface{} // Install command name
	Remove      interface{} // Remove command name
	Opts        []string    // Common pkg manager options
	InstallOpts []string    // Install pkg manager options
	RemoveOpts  []string    // Remove pkg manager options
	DryRunOpts  []string    // Check mode, do not run if absent
	// ActOpts []*Opt         // Action options
	// types.HasOS `mapstructure:",squash"` // OS   map[string][]string // Platform options
	// types.HasIf `mapstructure:",squash"` // If   map[string][]string // Conditional opts
	Env  map[string]string // Execution environment variables
	Init func() error      // Install manager or prepare bin
	Has  hasFunc           // Search local packages
	// contains filtered or unexported fields
}

Pm package manager

func NewPm

func NewPm(name string) (m *Pm, err error)

NewPm ...

func (*Pm) BuildOptions

func (m *Pm) BuildOptions(a string, pkgs []string, opts ...string) ([]string, error)

BuildOptions constructs the command arguments.

func (*Pm) Exec

func (m *Pm) Exec(args ...string) error

Exec TODO: return *exec.Cmd

func (*Pm) GetAction

func (m *Pm) GetAction(name string, input ...string) (string, error)

GetAction constructs the manager command for a given package.

func (*Pm) ParseOpts

func (m *Pm) ParseOpts(opts []string) (string, []string)

ParseOpts replaces bin with sudo if needed and prepend options with it.

Jump to

Keyboard shortcuts

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