Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.1 KB

README.md

File metadata and controls

37 lines (25 loc) · 1.1 KB

untree

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