aboutsummaryrefslogtreecommitdiff
path: root/bin/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-02 06:20:15 +0100
committerAkshay <[email protected]>2021-10-02 06:20:15 +0100
commit2dacf12a3df91f27e5f290dcf495378076da3eed (patch)
treeace54b172e1223ab96d927c00de0a6e4450abae7 /bin/src
parent7953d8cc9345794613ba2e7b90af9429579bc0cf (diff)
rename to statix, skip self env arg
Diffstat (limited to 'bin/src')
-rw-r--r--bin/src/main.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/bin/src/main.rs b/bin/src/main.rs
index 60afd5e..71cbb02 100644
--- a/bin/src/main.rs
+++ b/bin/src/main.rs
@@ -6,13 +6,13 @@ use std::{
6use anyhow::{Context, Result}; 6use anyhow::{Context, Result};
7use ariadne::{ 7use ariadne::{
8 CharSet, Color, Config as CliConfig, Label, Report as CliReport, 8 CharSet, Color, Config as CliConfig, Label, Report as CliReport,
9 ReportKind as CliReportKind, Source, 9 ReportKind as CliReportKind, Source, LabelAttach
10}; 10};
11use lib::{Report, LINTS}; 11use lib::{Report, LINTS};
12use rnix::{TextRange, WalkEvent}; 12use rnix::{TextRange, WalkEvent};
13 13
14fn analyze(file: &str) -> Result<Vec<Report>> { 14fn analyze(source: &str) -> Result<Vec<Report>> {
15 let parsed = rnix::parse(file).as_result()?; 15 let parsed = rnix::parse(source).as_result()?;
16 16
17 Ok(parsed 17 Ok(parsed
18 .node() 18 .node()
@@ -47,9 +47,12 @@ fn print_report(report: Report, file_src: &str, file_path: &Path) -> Result<()>
47 .with_config( 47 .with_config(
48 CliConfig::default() 48 CliConfig::default()
49 .with_cross_gap(true) 49 .with_cross_gap(true)
50 .with_char_set(CharSet::ExtendedAscii), 50 .with_multiline_arrows(false)
51 .with_label_attach(LabelAttach::Middle)
52 .with_char_set(CharSet::Unicode),
51 ) 53 )
52 .with_message(report.note), 54 .with_message(report.note)
55 .with_code(report.code),
53 |cli_report, diagnostic| { 56 |cli_report, diagnostic| {
54 let cli_report = cli_report.with_label( 57 let cli_report = cli_report.with_label(
55 Label::new((src_id, range(diagnostic.at))) 58 Label::new((src_id, range(diagnostic.at)))
@@ -74,8 +77,10 @@ fn print_report(report: Report, file_src: &str, file_path: &Path) -> Result<()>
74} 77}
75 78
76fn _main() -> Result<()> { 79fn _main() -> Result<()> {
80 // TODO: accept cli args, construct a CLI config with a list of files to analyze
77 let args = env::args(); 81 let args = env::args();
78 for (file_src, file_path, reports) in args 82 for (file_src, file_path, reports) in args
83 .skip(1)
79 .map(|s| PathBuf::from(&s)) 84 .map(|s| PathBuf::from(&s))
80 .filter(|p| p.is_file()) 85 .filter(|p| p.is_file())
81 .filter_map(|path| { 86 .filter_map(|path| {