Documentation
¶
Overview ¶
Package shellformat provides shell one-liner formatting for improved readability.
It parses shell commands using mvdan.cc/sh/v3/syntax (the shfmt parser) and reformats them with proper indentation and line breaks. The formatted output uses backslash continuations, making it valid shell that can be copy-pasted and executed directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
Format parses a shell one-liner and formats it with proper indentation and line breaks for readability. The formatted output uses backslash continuations and is valid shell that can be copy-pasted and executed.
Short statements that fit within the configured max width are kept on a single line. Longer statements have their binary operators (&&, ||, |) placed at the beginning of continuation lines.
On parse error, the original input is returned unchanged with a nil error.
Types ¶
type Option ¶
type Option func(*config)
Option configures the formatter.
func WithIndent ¶
WithIndent sets the indentation width in spaces (default: 2).
func WithMaxWidth ¶
WithMaxWidth sets the maximum line width threshold (default: 80). Statements shorter than this threshold are kept on a single line.
func WithVariant ¶
WithVariant sets the shell language variant (default: Bash).