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 ¶
- Variables
- type ErrorHandler
- type IPCCommunicator
- func (c *IPCCommunicator) HandleResponse(cmd *cobra.Command, ipcResponse ipc.Response) error
- func (c *IPCCommunicator) SendAndHandle(cmd *cobra.Command, action string, args []string) error
- func (c *IPCCommunicator) SendCommand(action string, args []string) (ipc.Response, error)
- func (c *IPCCommunicator) SetTimeout(timeoutSec int)
- type OutputFormatter
Constants ¶
This section is empty.
Variables ¶
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 ¶
HandleResponse processes an IPC response and handles success/error cases.
func (*IPCCommunicator) SendAndHandle ¶
SendAndHandle combines sending a command and handling the response.
func (*IPCCommunicator) SendCommand ¶
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 ¶
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.