2023-11-28 19:28:51 +03:00
|
|
|
mod bulk;
|
2023-11-23 16:34:12 +03:00
|
|
|
mod comment;
|
2023-11-25 19:30:43 +03:00
|
|
|
mod pasta;
|
2023-11-23 16:34:12 +03:00
|
|
|
mod position;
|
|
|
|
mod tests;
|
|
|
|
|
|
|
|
use clap::Parser;
|
2023-11-28 19:28:51 +03:00
|
|
|
use std::{collections::HashMap, path::PathBuf, println};
|
2023-11-23 16:34:12 +03:00
|
|
|
|
2023-11-25 19:30:43 +03:00
|
|
|
use crate::{
|
2023-11-29 14:53:29 +03:00
|
|
|
bulk::BulkProcessing,
|
|
|
|
pasta::Pasta,
|
2023-11-25 19:30:43 +03:00
|
|
|
position::{DocComment, DocIndex},
|
|
|
|
};
|
2023-11-23 16:34:12 +03:00
|
|
|
|
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
#[command(author, version, about)]
|
|
|
|
struct Options {
|
|
|
|
/// Json file containing a list of file positions.
|
|
|
|
/// Format: [{ file: String, line: Number, column: Number }]
|
|
|
|
#[arg(long, conflicts_with_all=["line", "column", "file"])]
|
|
|
|
pos_file: Option<PathBuf>,
|
|
|
|
|
|
|
|
/// Path to the *.nix file that should be inspected.
|
|
|
|
/// If provided, --line and --column must also be set.
|
|
|
|
#[arg(long, requires_all=["line", "column", "file"])]
|
|
|
|
file: Option<PathBuf>,
|
|
|
|
/// Line of the expression.
|
|
|
|
#[arg(short, long, requires_all=["line", "column", "file"])]
|
|
|
|
line: Option<usize>,
|
|
|
|
/// Column of the expression.
|
|
|
|
#[arg(short, long, requires_all=["line", "column", "file"])]
|
|
|
|
column: Option<usize>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
// let mut output = io::stdout();
|
|
|
|
let opts = Options::parse();
|
|
|
|
|
|
|
|
if let Some(nix_file) = opts.file {
|
2023-11-28 19:28:51 +03:00
|
|
|
let mut positions = HashMap::new();
|
|
|
|
positions.insert(opts.line.unwrap(), vec![opts.column.unwrap()]);
|
|
|
|
|
|
|
|
let pos = DocIndex::new(&nix_file, positions);
|
|
|
|
|
2023-11-23 16:34:12 +03:00
|
|
|
if let Some(docs) = pos.get_docs(opts.line.unwrap(), opts.column.unwrap()) {
|
|
|
|
println!("{:?}", docs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(pos_file) = opts.pos_file {
|
2023-11-29 14:53:29 +03:00
|
|
|
let data = Pasta::new(&pos_file);
|
2023-11-23 16:34:12 +03:00
|
|
|
}
|
|
|
|
}
|