2022-09-19 17:38:20 +04:00
|
|
|
mod docgen;
|
|
|
|
mod helpers;
|
|
|
|
mod path;
|
|
|
|
mod querycheck;
|
|
|
|
|
2021-11-21 22:55:08 +04:00
|
|
|
use std::{env, error::Error};
|
|
|
|
|
|
|
|
type DynError = Box<dyn Error>;
|
|
|
|
|
2021-11-17 17:30:11 +04:00
|
|
|
pub mod tasks {
|
2022-09-19 17:38:20 +04:00
|
|
|
use crate::docgen::{lang_features, typable_commands, write};
|
|
|
|
use crate::docgen::{LANG_SUPPORT_MD_OUTPUT, TYPABLE_COMMANDS_MD_OUTPUT};
|
|
|
|
use crate::querycheck::query_check;
|
2021-11-21 22:55:08 +04:00
|
|
|
use crate::DynError;
|
2021-11-17 17:30:11 +04:00
|
|
|
|
2021-11-21 22:55:08 +04:00
|
|
|
pub fn docgen() -> Result<(), DynError> {
|
|
|
|
write(TYPABLE_COMMANDS_MD_OUTPUT, &typable_commands()?);
|
|
|
|
write(LANG_SUPPORT_MD_OUTPUT, &lang_features()?);
|
|
|
|
Ok(())
|
2021-11-17 17:30:11 +04:00
|
|
|
}
|
|
|
|
|
2022-09-19 17:38:20 +04:00
|
|
|
pub fn querycheck() -> Result<(), DynError> {
|
|
|
|
query_check()
|
2022-08-26 02:24:09 +04:00
|
|
|
}
|
|
|
|
|
2021-11-17 17:30:11 +04:00
|
|
|
pub fn print_help() {
|
|
|
|
println!(
|
|
|
|
"
|
2021-11-21 22:55:08 +04:00
|
|
|
Usage: Run with `cargo xtask <task>`, eg. `cargo xtask docgen`.
|
2021-11-17 17:30:11 +04:00
|
|
|
|
|
|
|
Tasks:
|
2021-11-21 22:55:08 +04:00
|
|
|
docgen: Generate files to be included in the mdbook output.
|
2022-08-26 02:24:09 +04:00
|
|
|
query-check: Check that tree-sitter queries are valid.
|
2021-11-17 17:30:11 +04:00
|
|
|
"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 22:55:08 +04:00
|
|
|
fn main() -> Result<(), DynError> {
|
2021-11-17 17:30:11 +04:00
|
|
|
let task = env::args().nth(1);
|
|
|
|
match task {
|
|
|
|
None => tasks::print_help(),
|
|
|
|
Some(t) => match t.as_str() {
|
2021-11-21 22:55:08 +04:00
|
|
|
"docgen" => tasks::docgen()?,
|
2022-09-19 17:38:20 +04:00
|
|
|
"query-check" => tasks::querycheck()?,
|
2021-11-21 22:55:08 +04:00
|
|
|
invalid => return Err(format!("Invalid task name: {}", invalid).into()),
|
2021-11-17 17:30:11 +04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
Ok(())
|
|
|
|
}
|