Documentation
¶
Overview ¶
Package services Description: This file contains the implementation of the CommandServer interface for macOS and Linux.
Index ¶
Constants ¶
View Source
const (
CommandPromptDefault = `` /* 1621-byte string literal not displayed */
)
View Source
const (
CommandServerName comm.MoLingServerType = "Command"
)
Variables ¶
View Source
var ( // ErrCommandNotFound is returned when the command is not found. ErrCommandNotFound = fmt.Errorf("command not found") // ErrCommandNotAllowed is returned when the command is not allowed. ErrCommandNotAllowed = fmt.Errorf("command not allowed") )
Functions ¶
func ExecCommand ¶
ExecCommand executes a command and returns its output.
Types ¶
type CommandConfig ¶
type CommandConfig struct {
PromptFile string `json:"prompt_file"` // PromptFile is the prompt file for the command.
AllowedCommand string `json:"allowed_command"` // AllowedCommand is a list of allowed command. split by comma. e.g. ls,cat,echo
// contains filtered or unexported fields
}
CommandConfig represents the configuration for allowed commands.
func NewCommandConfig ¶
func NewCommandConfig() *CommandConfig
NewCommandConfig creates a new CommandConfig with the given allowed commands.
func (*CommandConfig) Check ¶
func (cc *CommandConfig) Check() error
Check validates the allowed commands in the CommandConfig.
type CommandServer ¶
CommandServer implements the Service interface and provides methods to execute named commands.
func (*CommandServer) Close ¶
func (cs *CommandServer) Close() error
func (*CommandServer) Config ¶
func (cs *CommandServer) Config() string
Config returns the configuration of the service as a string.
func (*CommandServer) Init ¶
func (cs *CommandServer) Init() error
func (*CommandServer) LoadConfig ¶
func (cs *CommandServer) LoadConfig(jsonData map[string]any) error
LoadConfig loads the configuration from a JSON object.
func (*CommandServer) Name ¶
func (cs *CommandServer) Name() comm.MoLingServerType
Click to show internal directories.
Click to hide internal directories.