loader: add TREE_SITTER_LIBDIR; cli: add --libdir to tree-sitter generate
Closes #1336
This commit is contained in:
parent
5088781ef9
commit
108d0ecede
2 changed files with 22 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::{anyhow, Context, Result};
|
||||
use clap::{App, AppSettings, Arg, SubCommand};
|
||||
use glob::glob;
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{env, fs, u64};
|
||||
use tree_sitter_cli::{
|
||||
generate, highlight, logger, parse, playground, query, tags, test, test_highlight, test_tags,
|
||||
|
|
@ -107,10 +107,18 @@ fn run() -> Result<()> {
|
|||
)
|
||||
.arg(Arg::with_name("no-bindings").long("no-bindings"))
|
||||
.arg(
|
||||
Arg::with_name("build").long("build").short("b")
|
||||
.help("Compile all defined languages in the current dir")
|
||||
Arg::with_name("build")
|
||||
.long("build")
|
||||
.short("b")
|
||||
.help("Compile all defined languages in the current dir"),
|
||||
)
|
||||
.arg(&debug_build_arg)
|
||||
.arg(
|
||||
Arg::with_name("libdir")
|
||||
.long("libdir")
|
||||
.takes_value(true)
|
||||
.value_name("path"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("report-states-for-rule")
|
||||
.long("report-states-for-rule")
|
||||
|
|
@ -276,6 +284,7 @@ fn run() -> Result<()> {
|
|||
let grammar_path = matches.value_of("grammar-path");
|
||||
let debug_build = matches.is_present("debug-build");
|
||||
let build = matches.is_present("build");
|
||||
let libdir = matches.value_of("libdir");
|
||||
let report_symbol_name = matches.value_of("report-states-for-rule").or_else(|| {
|
||||
if matches.is_present("report-states") {
|
||||
Some("")
|
||||
|
|
@ -305,6 +314,9 @@ fn run() -> Result<()> {
|
|||
report_symbol_name,
|
||||
)?;
|
||||
if build {
|
||||
if let Some(path) = libdir {
|
||||
loader = loader::Loader::with_parser_lib_path(PathBuf::from(path));
|
||||
}
|
||||
loader.use_debug_build(debug_build);
|
||||
loader.languages_at_path(¤t_dir)?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue