shellquote

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 4 Imported by: 0

README

shellquote

Shell argument quoting and prompt-file helpers for command templates.

Install

From pkg.go.dev:

go get github.com/brandonkramer/shellquote@v0.1.0

Usage

path, err := shellquote.WritePrompt(runDir, promptContent)
cmd := shellquote.SubstitutePrompt("cat {prompt}", path)
quoted := shellquote.Quote("/tmp/a file")

Constants:

  • shellquote.DefaultPromptFile"prompt.md"
  • shellquote.PromptPlaceholder"{prompt}"

Development

Lefthook and golangci-lint are pinned in go.mod as tools (dev-only). Install git hooks once per clone:

make install-hooks
make check
make test
make lint

Documentation

Overview

Package shellquote provides shell argument quoting and prompt-file helpers.

Use Quote and SubstitutePrompt when building shell command templates, and WritePrompt to materialize prompt content under a run directory.

Example:

path, err := shellquote.WritePrompt(runDir, prompt)
cmd := shellquote.SubstitutePrompt("cat {prompt}", path)

Index

Constants

View Source
const (
	// DefaultPromptFile is the default prompt filename under a run directory.
	DefaultPromptFile = "prompt.md"
	// PromptPlaceholder is substituted with a quoted prompt path in templates.
	PromptPlaceholder = "{prompt}"
)

Variables

This section is empty.

Functions

func PromptPath

func PromptPath(runDir string) string

PromptPath returns the default prompt file path under runDir.

func Quote

func Quote(s string) string

Quote wraps s in single quotes for POSIX shells.

func SubstitutePrompt

func SubstitutePrompt(template, promptPath string) string

SubstitutePrompt replaces PromptPlaceholder with a quoted promptPath in template.

func WritePrompt

func WritePrompt(runDir, content string) (string, error)

WritePrompt writes content to the default prompt file under runDir.

Types

This section is empty.

Jump to

Keyboard shortcuts

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