daemon

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken() (string, error)

GenerateToken returns a cryptographically random 32-byte hex string.

func LoadOrCreateToken

func LoadOrCreateToken() (string, error)

LoadOrCreateToken reads the token from disk, or generates and persists a new one.

func RunRemote

func RunRemote(addr, token string, args []string, version string) (int, error)

RunRemote connects to the daemon at addr, sends the CLI args, and returns the exit code. Stdout and stderr are written to os.Stdout and os.Stderr.

func TokenPath

func TokenPath() string

TokenPath returns the default path for the daemon token file.

Types

type BrowserOpener added in v0.7.0

type BrowserOpener interface {
	Open(url string) error
}

BrowserOpener opens a URL in the browser. Extracted for testability.

type Request

type Request struct {
	Version string            `json:"version"`
	Token   string            `json:"token"`
	Args    []string          `json:"args"`
	Env     map[string]string `json:"env,omitempty"`
}

Request is sent from the client to the daemon (one JSON line per connection).

type Response

type Response struct {
	Stdout        string `json:"stdout"`
	Stderr        string `json:"stderr"`
	ExitCode      int    `json:"exit_code"`
	AwaitCallback bool   `json:"await_callback,omitempty"`
	Callback      string `json:"callback,omitempty"`
}

Response is sent from the daemon back to the client (one or more JSON lines per connection).

type Server

type Server struct {
	Addr       string
	Token      string
	SafeMode   bool
	CmdFactory func() *cobra.Command
	Opener     BrowserOpener // used for OAuth relay; defaults to browser.DefaultOpener
	Logger     zerolog.Logger
}

Server listens for incoming client connections and executes CLI commands.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe starts the TCP listener and blocks until ctx is cancelled.

Jump to

Keyboard shortcuts

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