cmd

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Executor

func Executor(rq chan *CommandInput, wq chan *CommandOutput, cfgs []*CommandConfig)

func ExecutorWithRunner added in v0.2.0

func ExecutorWithRunner(
	rq chan *CommandInput,
	wq chan *CommandOutput,
	cfgs []*CommandConfig,
	runnerFactory RunnerFactory,
)

ExecutorWithRunner runs commands using runners provided by runnerFactory.

Types

type Cmd added in v0.2.0

type Cmd interface {
	SetStdin(r io.Reader)
	SetStdout(w io.Writer)
	SetStderr(w io.Writer)
	Run(timeout int) int
}

Cmd is an executable command abstraction for different runners.

type CommandConfig

type CommandConfig struct {
	*Definition
	ReplyConfig interface{} //*pubsub.ReplyConfig
}

func NewCommandConfig

func NewCommandConfig(def *Definition, replyConfig interface{}) *CommandConfig

type CommandInput

type CommandInput struct {
	ReplyInfo interface{} // PubSubの返信に必要な構造体(PubSubの種類ごとにキャストして利用する)
	Text      string      // 起動コマンド平文
}

CommandInput はPubSubからの情報をExecutorに引き渡す構造体

type CommandOutput

type CommandOutput struct {
	ReplyInfo   interface{}
	ReplyConfig interface{}
	Text        string // コマンドからのテキスト出力(ImageData と排他)
	ImageData   []byte // sixel を変換した PNG バイト列(Text と排他)
	IsErrOut    bool
	Spawned     bool
	Finished    bool
	ExitCode    int
}

CommandOutput はExecutorからの実行結果を引き渡してPubSubに書き出すための構造体

type CommandRunner added in v0.2.0

type CommandRunner interface {
	CommandContext(ctx context.Context, name string, arg ...string) Cmd
}

CommandRunner creates Cmd instances for a given command.

func NewComposeRunner added in v0.2.0

func NewComposeRunner(dir string, files ...string) CommandRunner

NewComposeRunner returns a runner backed by compose-exec. If dir is empty, it defaults to the current working directory.

func NewExecRunner added in v0.2.0

func NewExecRunner() CommandRunner

NewExecRunner returns a runner backed by os/exec.

func NewHTTPRunner added in v0.2.6

func NewHTTPRunner(cfg *CommandConfig) CommandRunner

NewHTTPRunner returns a runner backed by net/http.

type Definition

type Definition struct {
	Timeout int
	Keyword string
	Command string
	Runner  string
	Method  string
	URL     string
	Headers map[string]string
	Body    string
}

type Matcher

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

type OutputWriter

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

func (*OutputWriter) Flush

func (w *OutputWriter) Flush() error

func (*OutputWriter) Write

func (w *OutputWriter) Write(data []byte) (n int, err error)

type RunnerFactory added in v0.2.0

type RunnerFactory func(cfg *CommandConfig) CommandRunner

RunnerFactory returns a runner for the given command config.

Jump to

Keyboard shortcuts

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