on aa00a47 help sign in
helix/xtask/src/main.rs
61 lines 1.7 kB history raw
1mod docgen;
2mod helpers;
3mod path;
4mod querycheck;
5mod themelint;
7use std::{env, error::Error};
9type DynError = Box<dyn Error>;
11pub mod tasks {
12 use crate::docgen::{lang_features, typable_commands, write};
13 use crate::docgen::{LANG_SUPPORT_MD_OUTPUT, TYPABLE_COMMANDS_MD_OUTPUT};
14 use crate::querycheck::query_check;
15 use crate::themelint::{lint, lint_all};
16 use crate::DynError;
18 pub fn docgen() -> Result<(), DynError> {
19 write(TYPABLE_COMMANDS_MD_OUTPUT, &typable_commands()?);
20 write(LANG_SUPPORT_MD_OUTPUT, &lang_features()?);
21 Ok(())
22 }
24 pub fn themelint(file: Option<String>) -> Result<(), DynError> {
25 match file {
26 Some(file) => lint(file),
27 None => lint_all(),
28 }
29 }
31 pub fn querycheck() -> Result<(), DynError> {
32 query_check()
33 }
35 pub fn print_help() {
36 println!(
37 "
38Usage: Run with `cargo xtask <task>`, eg. `cargo xtask docgen`.
40 Tasks:
41 docgen: Generate files to be included in the mdbook output.
42 themelint <theme>: Report errors for <theme>, or all themes if no theme is specified.
43 query-check: Check that tree-sitter queries are valid.
45 );
46 }
49fn main() -> Result<(), DynError> {
50 let task = env::args().nth(1);
51 match task {
52 None => tasks::print_help(),
53 Some(t) => match t.as_str() {
54 "docgen" => tasks::docgen()?,
55 "themelint" => tasks::themelint(env::args().nth(2))?,
56 "query-check" => tasks::querycheck()?,
57 invalid => return Err(format!("Invalid task name: {}", invalid).into()),
58 },
59 };
60 Ok(())