cli

package
v0.0.0-...-279fa12 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Command-line options and utilities used by multiple cmds.

Index

Constants

View Source
const (
	DeviceSerialFlag = "device"
	MountpointFlag   = "mountpoint"
)
View Source
const (
	MountRootFlag        = "root"
	PathToAdbfsFlag      = "adbfs"
	AllowAnyAdbfsFlag    = "disable-adbfs-verify"
	OnMountHandlerFlag   = "on-mount"
	OnUnmountHandlerFlag = "on-unmount"
)
View Source
const (
	DefaultPoolSize = 2
	DefaultCacheTtl = 300 * time.Millisecond
	DefaultLogLevel = logrus.InfoLevel
)
View Source
const (
	AdbPortFlag            = "port"
	ConnectionPoolSizeFlag = "pool"
	CacheTtlFlag           = "cachettl"
	LogLevelFlag           = "log"
	VerboseFlag            = "verbose"
	ServeDebugFlag         = "debug"
	DeviceRootFlag         = "device-root"
	ReadOnlyFlag           = "readonly"
	PathToAdb              = "adb"
)
View Source
const (
	PathHandlerVar   = "ADBFS_PATH"
	SerialHandlerVar = "ADBFS_SERIAL"
	ModelHandlerVar  = "ADBFS_MODEL"
)
View Source
const MountpointPerm os.FileMode = 0700

Permissions for mountpoint directories.

View Source
const Version = "1.0.0"

Variables

Functions

func CheckExecutableVersionMatches

func CheckExecutableVersionMatches(path, appName, version string) error

CheckExecutableVersionMatches returns an error if running "$path --version" does not give output indicating that it is appName with version. If version is empty, ignores the version number as long as the appName matches.

func FindDefaultMountRoot

func FindDefaultMountRoot() string

func FireHandlers

func FireHandlers(handlers []string, values map[string]string)

FireHandlers executes each handler in handlers with all occurrences of $key or ${key} replaced with values[key]. The map keys should be the *HandlerVar constants.

func Initialize

func Initialize(appName string, baseConfig *BaseConfig)

Initialize sets the app name. Must be called before flag.Parse()

func NewMountpointForDevice

func NewMountpointForDevice(deviceInfo *adb.DeviceInfo, mountRoot, serial string) (mountpoint string, err error)

func RegisterAdbfsFlags

func RegisterAdbfsFlags(config *AdbfsConfig)

func RegisterAutomountFlags

func RegisterAutomountFlags(config *AutomountConfig)

Types

type AdbfsConfig

type AdbfsConfig struct {
	BaseConfig

	DeviceSerial string
	Mountpoint   string
}

func (*AdbfsConfig) AsArgs

func (c *AdbfsConfig) AsArgs() []string

type AutomountConfig

type AutomountConfig struct {
	BaseConfig

	MountRoot         string
	PathToAdbfs       string
	AllowAnyAdbfs     bool
	OnMountHandlers   []string
	OnUnmountHandlers []string
}

func (*AutomountConfig) InitializePaths

func (c *AutomountConfig) InitializePaths()

type BaseConfig

type BaseConfig struct {
	// Command-line arguments. Each variable in this block should have a line in AsArgs().
	AdbPort            int
	ConnectionPoolSize int
	LogLevel           string
	Verbose            bool
	CacheTtl           time.Duration
	ServeDebug         bool
	DeviceRoot         string
	ReadOnly           bool
	PathToAdb          string
}

func (*BaseConfig) AsArgs

func (c *BaseConfig) AsArgs() []string

AsArgs returns a string array suitable to be passed to exec.Command that copies the arguments defined in this package.

func (*BaseConfig) ServerConfig

func (c *BaseConfig) ServerConfig() adb.ServerConfig

ServerConfig returns a adb.ServerConfig from CLI arguments.

type EventLog

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

EventLog wraps trace.EventLog with logging calls to cli.Log.

func NewEventLog

func NewEventLog(family, title string) *EventLog

func (*EventLog) Debugf

func (l *EventLog) Debugf(format string, a ...interface{})

func (*EventLog) Errorf

func (l *EventLog) Errorf(format string, a ...interface{})

func (*EventLog) Finish

func (l *EventLog) Finish()

func (*EventLog) Infof

func (l *EventLog) Infof(format string, a ...interface{})

type Process

type Process func(key string, ctx context.Context)

type ProcessInfo

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

type ProcessTracker

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

ProcessTracker manages multiple goroutines that are deduped by a key and are associated with a stop channel.

func NewProcessTracker

func NewProcessTracker() *ProcessTracker

func (*ProcessTracker) Go

func (t *ProcessTracker) Go(key string, proc Process) (procInfo *ProcessInfo, err error)

func (*ProcessTracker) Shutdown

func (t *ProcessTracker) Shutdown()

Jump to

Keyboard shortcuts

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