-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
39 lines (35 loc) · 1.02 KB
/
main.rs
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
#!/usr/bin/env rust-script
//! Dependencies can be specified in the script file itself as follows:
//!
//! ```cargo
//! [dependencies]
//! rand = "0.8.0"
//! time = "0.3.17"
//! ```
// use rand::prelude::*;
use std::env;
use std::process::Command;
use std::io::{self, Write};
fn main() {
let args: Vec<String> = env::args().collect();
// dbg!(args);
// let x: u64 = random();
// println!("A random number: {}", x);
let year: i32;
let day: i32;
if args.len() == 2 {
year = time::OffsetDateTime::now_utc().date().year();
day = args[1].parse::<i32>().unwrap();
} else {
year = args[1].parse::<i32>().unwrap();
day = args[2].parse::<i32>().unwrap();
}
// println!("Running: {} {}", year, day);
let path = format!("{year}/day{day}/day{day}.rs");
let output = Command::new("rust-script")
.args([&path])
.output()
.expect("failed");
io::stdout().write_all(&output.stdout).unwrap();
io::stdout().write_all(&output.stderr).unwrap();
}