treequery

command module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 13 Imported by: 0

README

Go Report Card BuildStatus

treequery

treequery is a CLI for executing Tree-sitter queries on source code files. It uses enry to detect a language and apply the right Tree-sitter parser. The default output includes a list of line number locations where there's a query match, followed by a snippet of the matching code.

Getting Started

Running make in the root of this repo will produce a tq binary, which can be used as such:

> ./tq testdata/TriestBase.java "(method_declaration name: (identifier) @method_name)"
./treequery/testdata/TriestBase.java:20
handleEdge
./treequery/testdata/TriestBase.java:48
swapIn
./treequery/testdata/TriestBase.java:53
addEdge
./treequery/testdata/TriestBase.java:88
removeEdge
./treequery/testdata/TriestBase.java:119
getEstimate

The above example shows a way to select all method names in the testdata/TriestBase.java file. To exclude file names and line locations, use the -q (quiet) flag:

handleEdge
swapIn
addEdge
removeEdge
getEstimate

Supported Languages

  • bash
  • c
  • cpp
  • csharp
  • css
  • elm
  • golang
  • html
  • java
  • javascript
  • lua
  • ocaml
  • php
  • python
  • ruby
  • rust
  • scala
  • svelte
  • toml
  • typescript
  • yaml

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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