Initial commit
This commit is contained in:
48
src/main.rs
Normal file
48
src/main.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
use chrono::{Datelike, Local};
|
||||
use clap::{Parser, Subcommand};
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about = "A simple CLI tool example", long_about = None)]
|
||||
struct Args {
|
||||
#[command(subcommand)]
|
||||
command: Option<Commands>,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
/// Greets the specified person
|
||||
Greet {
|
||||
/// The name of the person to greet
|
||||
name: String,
|
||||
},
|
||||
/// Performs a simple calculation
|
||||
Calculate {
|
||||
/// The first number
|
||||
num1: i32,
|
||||
/// The second number
|
||||
num2: i32,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let DAILY_FILEPATH = match env::var("VIMTODAY_DAILY_FILEPATH") {
|
||||
Ok(val) => val,
|
||||
Err(_e) => String::from("oops")
|
||||
};
|
||||
let today = Local::now();
|
||||
let today_date_str = format!("{}-{:02}-{:02}", today.year(), today.month(), today.day());
|
||||
|
||||
|
||||
let file_path = format!("{}/{}/{}", &DAILY_FILEPATH, today.year(), &today_date_str);
|
||||
|
||||
println!("vim {}", file_path);
|
||||
|
||||
Command::new("vim")
|
||||
.arg(&file_path)
|
||||
.status()
|
||||
.expect("process failed to execute");
|
||||
}
|
||||
Reference in New Issue
Block a user