Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit b533b31

Browse files
author
Hendrik van Antwerpen
committed
Always enable both TS & TSX in CLI
1 parent 56a619f commit b533b31

File tree

1 file changed

+16
-38
lines changed
  • languages/tree-sitter-stack-graphs-typescript/rust

1 file changed

+16
-38
lines changed

languages/tree-sitter-stack-graphs-typescript/rust/bin.rs

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,34 @@
66
// ------------------------------------------------------------------------------------------------
77

88
use anyhow::anyhow;
9-
use clap::{Parser, ValueEnum};
9+
use clap::Parser;
1010
use tree_sitter_stack_graphs::cli::database::default_user_database_path_for_crate;
1111
use tree_sitter_stack_graphs::cli::provided_languages::Subcommands;
12-
use tree_sitter_stack_graphs::loader::{LanguageConfiguration, LoadError};
1312
use tree_sitter_stack_graphs::NoCancellation;
1413

15-
/// Flag to select the dialect of the language
16-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
17-
pub enum Dialect {
18-
Typescript,
19-
TSX,
20-
}
21-
2214
fn main() -> anyhow::Result<()> {
2315
let cli = Cli::parse();
24-
let lc = match language_configuration(cli.dialect) {
25-
Ok(lc) => lc,
26-
Err(err) => {
27-
eprintln!("{}", err.display_pretty());
28-
return Err(anyhow!("Language configuration error"));
29-
}
30-
};
31-
let default_db_path = default_user_database_path_for_crate(env!("CARGO_PKG_NAME"))?;
32-
cli.subcommand.run(default_db_path, vec![lc])
33-
}
34-
35-
fn language_configuration<'a>(dialect: Dialect) -> Result<LanguageConfiguration, LoadError<'a>> {
36-
match dialect {
37-
Dialect::Typescript => {
38-
tree_sitter_stack_graphs_typescript::try_language_configuration_typescript(
39-
&NoCancellation,
40-
)
41-
}
42-
Dialect::TSX => {
43-
tree_sitter_stack_graphs_typescript::try_language_configuration_tsx(&NoCancellation)
44-
}
16+
let mut lcs = Vec::new();
17+
for r in [
18+
tree_sitter_stack_graphs_typescript::try_language_configuration_typescript(&NoCancellation),
19+
tree_sitter_stack_graphs_typescript::try_language_configuration_tsx(&NoCancellation),
20+
] {
21+
let lc = match r {
22+
Ok(lc) => lc,
23+
Err(err) => {
24+
eprintln!("{}", err.display_pretty());
25+
return Err(anyhow!("Language configuration error"));
26+
}
27+
};
28+
lcs.push(lc);
4529
}
30+
let default_db_path = default_user_database_path_for_crate(env!("CARGO_PKG_NAME"))?;
31+
cli.subcommand.run(default_db_path, lcs)
4632
}
4733

4834
#[derive(Parser)]
4935
#[clap(about, version)]
5036
pub struct Cli {
51-
#[clap(
52-
short,
53-
long,
54-
value_enum,
55-
default_value_t = Dialect::Typescript,
56-
)]
57-
dialect: Dialect,
58-
5937
#[clap(subcommand)]
6038
subcommand: Subcommands,
6139
}

0 commit comments

Comments
 (0)