untree

like gron, but generalised on indentation

MIT License

Stars
14

untree finds and flattens tree-like text, making it easily searchable. for example prefixing all expressions a codebase with their parent function definitions, all HTML tags with their parent tags, or JSON objects their parent keys names.

all that's required is indentation with spaces or tabs

(like gron, but generalised on indentation)


installation

    $ go install go.senan.xyz/untree@latest

usage

    $ cmd | untree
    $ untree [FILE ...]

the output format is <prefix>\t<original line>. suitable for grepping, piping, column selecting. eg "all Go handler functions which log under a certain condition" could be

untree "$(git ls-files "*.go")" \
    | grep "func.*Handle.*if.*err :=.*slog.Info" \
    | awk '{ print $2 }'`

examples

Package Rankings
Top 7.47% on Proxy.golang.org