cli

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ShellCommandPath = "/usr/local/bin/huncrow"

ShellCommandPath is the installation path for the macOS shell command.

Variables

View Source
var (
	ErrHelp    = errors.New("help requested")
	ErrVersion = errors.New("version requested")
)
View Source
var (
	ErrConflict     = errors.New("cli: shell command path is already in use")
	ErrNotOurs      = errors.New("cli: shell command does not point to this executable")
	ErrNotInstalled = errors.New("cli: application is not installed in a stable location")
	ErrCanceled     = errors.New("cli: administrator authorization was canceled")
)

Functions

func Detach

func Detach(exe string, args []string) error

Detach starts the executable in a new session and releases the process handle.

func Executable

func Executable() (string, error)

Executable returns the absolute, symlink-resolved application executable. Launches from App Translocation or a mounted volume return ErrNotInstalled.

func InstallShellCommand

func InstallShellCommand(ctx context.Context, link, exe string, elev Elevator) error

InstallShellCommand makes link a symlink to exe, replacing a symlink to anywhere else; any other entry at link returns ErrConflict. It requests administrator privileges through elev only when the direct attempt encounters a permission error.

func ShouldDetach

func ShouldDetach(getenv func(string) string, dev bool) bool

ShouldDetach reports whether the application was launched from a terminal.

func UninstallShellCommand

func UninstallShellCommand(ctx context.Context, link, exe string, elev Elevator) error

UninstallShellCommand removes only a symlink to exe. An absent command or a conflicting filesystem entry returns ErrNotOurs.

func Usage

func Usage(name string) string

Usage returns the English command-line help for name.

Types

type ArgumentOpenFiles added in v0.1.0

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

ArgumentOpenFiles tracks expected OnOpenFile callbacks for files in a CLI request. It must only be used on the application's main goroutine.

func (*ArgumentOpenFiles) Clear added in v0.1.0

func (f *ArgumentOpenFiles) Clear()

Clear forgets any callbacks MyGo did not deliver.

func (*ArgumentOpenFiles) Consume added in v0.1.0

func (f *ArgumentOpenFiles) Consume(path string) bool

Consume skips one expected callback for path.

type Elevator

type Elevator interface {
	RunAdmin(ctx context.Context, script string) error
}

Elevator runs a shell script with administrator privileges.

type OSAScriptElevator

type OSAScriptElevator struct{}

OSAScriptElevator requests administrator authorization on macOS.

func (OSAScriptElevator) RunAdmin

func (OSAScriptElevator) RunAdmin(ctx context.Context, script string) error

RunAdmin runs script through macOS's administrator authorization dialog.

type Request

type Request struct {
	Folders     []string
	Files       []Target
	ReuseWindow bool
	NewWindow   bool
	Missing     []string
}

Request contains the paths and window preferences for a CLI invocation.

func Parse

func Parse(args []string, wd string) (Request, error)

Parse interprets arguments without the program name and resolves paths from wd.

func (Request) ArgumentOpenFiles added in v0.1.0

func (r Request) ArgumentOpenFiles(args []string, wd string, extensions []string) *ArgumentOpenFiles

ArgumentOpenFiles counts the paths MyGo v0.10.0 will redeliver from raw arguments. MyGo checks each argument on its own, even when Parse deduplicates equivalent paths or strips its --goto suffix.

func (Request) Empty

func (r Request) Empty() bool

Empty reports whether the request had no paths.

type Status

type Status struct {
	Installed bool
	Conflict  bool
	Target    string
}

Status describes the installed shell command. Its zero value means the path is absent. Target is the raw destination of a conflicting symlink and is empty when a different kind of entry occupies the path.

func ShellCommandStatus

func ShellCommandStatus(link, exe string) (Status, error)

ShellCommandStatus inspects link without changing the filesystem.

type Target

type Target struct {
	Path         string
	Line, Column int
}

Target is a file with an optional one-based line and column.

type UsageError

type UsageError struct {
	Arg string
	// contains filtered or unexported fields
}

UsageError identifies an invalid command-line argument.

func (*UsageError) Error

func (e *UsageError) Error() string

Jump to

Keyboard shortcuts

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