install

package
v0.0.0-...-5d27ecb Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executable

type Executable interface {
	// BinaryPath returns the current binary path of the executable.
	BinaryPath() (string, error)
}

Executable defines an abstraction over the current binary executable.

type ExecutableFn

type ExecutableFn func() (string, error)

ExecutableFn is used to return the current binary path, so that we know which application to call when inserting the completion command.

type Installer

type Installer struct {
	// contains filtered or unexported fields
}

Installer represents a series of different shell installers. Calling Install and Uninstall to add and remove the correct shell installer commands retrospectively.

func New

func New(options ...InstallerOption) (*Installer, error)

New creates a new installer with the correct dependencies and sane defaults. Returns an error if it can't locate the correct binary path.

func (*Installer) Install

func (i *Installer) Install(cmd string) error

Install takes a command argument and installs the command for the shell

func (*Installer) Uninstall

func (i *Installer) Uninstall(cmd string) error

Uninstall removes the auto-complete installer shell

type InstallerOption

type InstallerOption func(InstallerOptions)

InstallerOption captures a tweak that can be applied to the Installer.

func OptionExecutable

func OptionExecutable(exec Executable) InstallerOption

OptionExecutable allows the setting and appending of a exec option to configure the installer.

func OptionShell

func OptionShell(shell *Shell) InstallerOption

OptionShell allows the setting and appending of a shell option to configure the installer.

type InstallerOptions

type InstallerOptions interface {
	AppendShell(*Shell)
	SetExecutable(Executable)
}

InstallerOptions represents a way to set optional values to a installer option. The InstallerOptions shows what options are available to change.

type OSExecutable

type OSExecutable struct{}

OSExecutable is a wrapper around the OS package to provide the binary path for the current executable.

func (OSExecutable) BinaryPath

func (e OSExecutable) BinaryPath() (string, error)

BinaryPath returns the binary path as an absolute file path.

type OSUser

type OSUser struct {
	// contains filtered or unexported fields
}

OSUser represents a current operating system user.

func CurrentUser

func CurrentUser() (OSUser, error)

CurrentUser returns the current operating system user. If there is an error trying to get the current user, it returns an error.

func (OSUser) HomeDir

func (u OSUser) HomeDir() string

HomeDir returns the current home directory for the os user.

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell represents a shell for installing and uninstalling autocomplete commands in the correct shell files.

func Bash

func Bash(options ...ShellOption) *Shell

Bash creates a new Shell with the file locations and the correct bash complete command.

func Zsh

func Zsh(options ...ShellOption) *Shell

Zsh creates a new Shell with the file locations and the correct zsh complete command.

func (*Shell) Install

func (b *Shell) Install(cmd, bin string) error

Install attempts to install an autocomplete command into the correct file locations for that shell. Returns an error if the command already exists or if appending to a file is not possible.

func (*Shell) Uninstall

func (b *Shell) Uninstall(cmd, bin string) error

Uninstall attempts to uninstall the autocomplete command from the shell files. Returns an error if it's unable to modify the profile file.

type ShellOption

type ShellOption func(ShellOptions)

ShellOption captures a tweak that can be applied to the Shell.

func OptionFileSystem

func OptionFileSystem(fs fsys.FileSystem) ShellOption

OptionFileSystem allows the setting a filesystem option to configure the shell.

func OptionUser

func OptionUser(u User) ShellOption

OptionUser allows the setting a user option to configure the shell.

type ShellOptions

type ShellOptions interface {
	SetFileSystem(fsys.FileSystem)
	SetUser(User)
}

ShellOptions represents a way to set optional values to a installer option. The ShellOptions shows what options are available to change.

type User

type User interface {

	// HomeDir returns the home directory of the current User.
	HomeDir() string
}

User is an abstraction around the current User.

Jump to

Keyboard shortcuts

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