Skip to content

Commit 2274139

Browse files
committed
Small cleanups
1 parent 5c40e45 commit 2274139

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/main.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
use anyhow::{Context, Result};
1+
use anyhow::Context;
22
use minijinja::Environment;
3-
use std::path::PathBuf;
4-
use std::{env, fs};
3+
use std::{collections::HashMap, env, fs, process};
54

6-
fn main() -> Result<()> {
5+
fn main() -> anyhow::Result<()> {
76
let mut args = env::args();
87
if args.len() != 2 {
98
let name = args.next().unwrap();
109
eprintln!("Usage: {} <template_file>", name);
11-
std::process::exit(1);
10+
process::exit(1);
1211
}
1312

14-
let template_path = PathBuf::from(args.nth(1).unwrap());
15-
let template = fs::read_to_string(&template_path)
16-
.with_context(|| format!("Failed to read template file: {}", template_path.display()))?;
13+
let path = args.nth(1).unwrap();
14+
let template = fs::read_to_string(&path)
15+
.with_context(|| format!("Failed to read template file: {}", path))?;
1716

1817
let mut env = Environment::new();
1918
env.add_template("template", &template)?;
2019

2120
let tmpl = env.get_template("template")?;
22-
let ctx = env::vars().collect::<std::collections::HashMap<_, _>>();
21+
let ctx = env::vars().collect::<HashMap<_, _>>();
2322

2423
let output = tmpl.render(&ctx)?;
2524
println!("{}", output);

0 commit comments

Comments
 (0)