-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathmain.rs
More file actions
41 lines (36 loc) · 1.02 KB
/
main.rs
File metadata and controls
41 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::path::PathBuf;
use crate::cmd_args::Format;
use clap::Parser;
use cmd_args::CmdArgs;
mod cmd_args;
mod common;
mod init;
mod json_generator;
mod markdown_generator;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = CmdArgs::parse();
let current_path = std::env::current_dir()?;
let input = args.input;
let mut files: Vec<PathBuf> = Vec::new();
for path in input {
if path.is_relative() {
files.push(current_path.join(path));
} else {
files.push(path);
}
}
let mut analysis = match init::load_workspace(files) {
Some(a) => a,
None => return Err("failed to load workspace".into()),
};
match args.format {
Format::Markdown => markdown_generator::generate_markdown(
&mut analysis,
args.output,
args.override_template,
args.site_name,
args.mixin,
),
Format::Json => json_generator::generate_json(&mut analysis, args.output),
}
}