execligo

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 8 Imported by: 0

README

execligo

A module that executes arbitrary commands via Go.
It also features an LLM-friendly error output method.

OS-dependent information

  • Linux: sh
  • Windows: PowerShell version 7 or later

Usage / Execution method

go run ./cmd/execligo-sample/main.go
Execute this command?: date && echo 'World!'
[y/N]: y
Executed Command: date && echo 'World!'
Exit Code: 0
--- STDOUT ---

2026年4月25日 18:59:46
World!
Execute this command?: date && echo 'World!'
[y/N]: n
Executed Command: date && echo 'World!'
Exit Code: 130
--- STDERR ---
Execution rejected by approval process.
--- System Error ---
not approved

Example implementation of type ApprovalFunc func(command string) bool

func ConsoleApprovalSample(cmd string) bool {
    fmt.Printf("Execute this command?: %s\n[y/N]: ", cmd)
    var input string
    fmt.Scanln(&input)
    return strings.ToLower(input) == "y"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeOutput

func DecodeOutput(raw []byte) string

デコードしてstring型で出力

Types

type ApprovalFunc

type ApprovalFunc func(command string) bool

ユーザーの承認を得るための関数型定義

type CommandResult

type CommandResult struct {
	Command  string
	Stdout   string
	Stderr   string
	ExitCode int
	Error    error
}

実行したコマンドとその結果を格納する構造体

func ExecuteCommand

func ExecuteCommand(command string, approvalCheck ApprovalFunc) CommandResult

任意のシェルコマンドを実行する。 bool を返す関数である approvalCheck が nil でないとき、承認プロセスを行う。

func (CommandResult) ToLLMString

func (r CommandResult) ToLLMString() string

LLMに出力を渡すために整形

Directories

Path Synopsis
cmd
execligo-sample command

Jump to

Keyboard shortcuts

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