diff options
| -rw-r--r-- | Cargo.lock | 107 | ||||
| -rw-r--r-- | Cargo.toml | 8 | ||||
| -rw-r--r-- | src/main.rs | 61 |
3 files changed, 176 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f7be8a3 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,107 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "future-me" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "proc-macro2" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "serde" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + +[[package]] +name = "syn" +version = "2.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..ab405c3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "future-me" +version = "0.1.0" +edition = "2024" + +[dependencies] +serde = { version = "1.0.145", features = ["derive"] } +serde_json = "1.0.145" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..7248942 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,61 @@ +use serde::{Deserialize, Serialize}; +//use serde_json::Result; +use std::time::{SystemTime, UNIX_EPOCH}; +use std::{ + env::{temp_dir, var}, + fs::File, + io::Read, + process::Command, +}; +use std::fs; + +#[derive(Serialize, Deserialize)] +struct BugReport { + timestamp: String, + status: String, + title: String, + description: Vec<String>, + tags: Option<String>, + version: String +} + +fn new_bug() { + let editor = var("EDITOR").unwrap(); + let mut file_path = temp_dir(); // TODO: figgure out how to get .git dir in a save manner + file_path.push("NEW_BUG_REPORT"); + File::create(&file_path).expect("Could not create file"); + + Command::new(editor) + .arg(&file_path) + .status() + .expect("Something went wrong"); + + let mut new_bug_report = String::new(); + let _ = File::open(&file_path) + .expect("Could not open file") + .read_to_string(&mut new_bug_report); + let _ = fs::remove_file(&file_path); + let mut header = ""; + let mut description: Vec::<String> = Vec::new(); + for (i, line) in new_bug_report.lines().enumerate() { + match i { + 0 => header = line, + 1 => (), + _ => description.push(line.to_string()), + } + } + let report = BugReport { + timestamp: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs().to_string(), + title: header.to_owned(), + description: description.to_owned(), + status: "new".to_owned(), + tags: None, + version: "v1".to_owned(), + }; + let j = serde_json::to_string(&report).unwrap(); + print!("{}", j); +} + +fn main() { + new_bug(); +} |
