cliutil

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cliutil provides shared utilities for CLI command implementations.

This package contains common patterns and utilities used across CLI commands, including IPC communication helpers, command builders, and output formatters.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnhealthy = errors.New("unhealthy components detected")

ErrUnhealthy is returned by PrintHealth when one or more components are unhealthy.

Functions

This section is empty.

Types

type ErrorHandler

type ErrorHandler struct{}

ErrorHandler provides consistent error handling for CLI commands.

func NewErrorHandler

func NewErrorHandler() *ErrorHandler

NewErrorHandler creates a new error handler.

func (*ErrorHandler) HandleIPCError

func (e *ErrorHandler) HandleIPCError(err error, context string) error

HandleIPCError wraps IPC errors with consistent formatting.

func (*ErrorHandler) HandleSerializationError

func (e *ErrorHandler) HandleSerializationError(err error, context string) error

HandleSerializationError wraps serialization errors.

type IPCCommunicator

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

IPCCommunicator handles IPC communication with the Neru daemon.

func NewIPCCommunicator

func NewIPCCommunicator(timeoutSec int) *IPCCommunicator

NewIPCCommunicator creates a new IPC communicator.

func (*IPCCommunicator) HandleResponse

func (c *IPCCommunicator) HandleResponse(cmd *cobra.Command, ipcResponse ipc.Response) error

HandleResponse processes an IPC response and handles success/error cases.

func (*IPCCommunicator) SendAndHandle

func (c *IPCCommunicator) SendAndHandle(cmd *cobra.Command, action string, args []string) error

SendAndHandle combines sending a command and handling the response.

func (*IPCCommunicator) SendCommand

func (c *IPCCommunicator) SendCommand(action string, args []string) (ipc.Response, error)

SendCommand sends a command to the running Neru daemon.

func (*IPCCommunicator) SetTimeout

func (c *IPCCommunicator) SetTimeout(timeoutSec int)

SetTimeout updates the timeout for IPC operations.

type OutputFormatter

type OutputFormatter struct{}

OutputFormatter handles formatted output for CLI commands.

func NewOutputFormatter

func NewOutputFormatter() *OutputFormatter

NewOutputFormatter creates a new output formatter.

func (*OutputFormatter) PrintHealth

func (f *OutputFormatter) PrintHealth(cmd *cobra.Command, success bool, data any) error

PrintHealth prints health check results.

func (*OutputFormatter) PrintStatus

func (f *OutputFormatter) PrintStatus(cmd *cobra.Command, data any) error

PrintStatus prints status information in a formatted way.

Jump to

Keyboard shortcuts

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