docs/src/cli/query.md
tree-sitter queryThe query command is used to run a query on a parser, and view the results.
tree-sitter query [OPTIONS] <QUERY_PATH> [PATHS]... # Aliases: q
-p/--grammar-path <PATH>The path to the directory containing the grammar.
--lib-pathThe path to the parser's dynamic library. This is used instead of the cached or automatically generated dynamic library.
--lang-nameIf --lib-path is used, the name of the language used to extract the library's language function
-t/--timePrint the time taken to execute the query on the file.
-q/--quietSuppress main output.
--paths <PATHS_FILE>The path to a file that contains paths to source files in which the query will be executed.
--byte-range <BYTE_RANGE>The range of byte offsets in which the query will be executed. The format is start_byte:end_byte.
--containing-byte-range <BYTE_RANGE>The range of byte offsets in which the query will be executed. Only the matches that are fully contained within the provided byte range will be returned.
--row-range <ROW_RANGE>The range of rows in which the query will be executed. The format is start_row:end_row.
--containing-row-range <ROW_RANGE>The range of rows in which the query will be executed. Only the matches that are fully contained within the provided row range will be returned.
--scope <SCOPE>The language scope to use for parsing and querying. This is useful when the language is ambiguous.
-c/--capturesOrder the query results by captures instead of matches.
--testWhether to run query tests or not.
--config-path <CONFIG_PATH>The path to an alternative configuration (config.json) file. See the init-config command for more information.
-n/--test-number <TEST_NUMBER>Query the contents of a specific test.
-r/--rebuildForce a rebuild of the parser before executing the query.