From 4778a3c217f2a7a7fe67110123df392e205797cd Mon Sep 17 00:00:00 2001 From: Jan Allersma Date: Feb 01 2019 14:59:24 +0000 Subject: Integrate 'ambassade-debug' crate. Revise `backend::config::check()` function. --- diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..6569cdb --- /dev/null +++ b/.cargo/config @@ -0,0 +1,3 @@ +[target.x86_64-pc-windows-gnu] +linker = "x86_64-w64-mingw32-gcc" +ar = "x86_64-w64-mingw32-gcc-ar" diff --git a/Cargo.lock b/Cargo.lock index 0a862b0..876eb3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,13 +1,22 @@ [[package]] name = "ambassade" -version = "1.0.0" +version = "1.0.1" dependencies = [ + "ambassade-debug 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustyline 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "ambassade-debug" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "argon2rs" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -472,6 +481,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] +"checksum ambassade-debug 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4b97e2b45a21933ae06aa7475c012b5048cce72c7ec95e2166b54037e737a0" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" diff --git a/Cargo.toml b/Cargo.toml index 53ed450..1d5ddb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,10 @@ [package] name = "ambassade" -version = "1.0.0" +version = "1.0.1" authors = ["Jan Allersma "] [dependencies] serde_json = "1.0" rustyline = "2.1.0" git2 = "0.8" +ambassade-debug = "^0" diff --git a/src/backend/config.rs b/src/backend/config.rs index d301561..7a70737 100644 --- a/src/backend/config.rs +++ b/src/backend/config.rs @@ -55,7 +55,7 @@ pub fn update(path: &PathBuf, value: serde_json::Value) -> Result<(), String> { fn read(path: &PathBuf) -> Result { let mut config = String::new(); - check(&path); + check(path); match File::open(path.to_str().unwrap()) { Ok(mut file) => { @@ -91,14 +91,22 @@ fn check(config: &PathBuf) { let mut input = String::new(); println!("'{}' not found. ", config.to_str().unwrap()); - println!("Initialize module with new config file [y/N]?"); - match io::stdin().read_line(&mut input) { - Ok(_) if input.as_str() == "y\n" => match init(config) { - Ok(_) => {}, - Err(e) => println!("Module initialization failed. Details: {}", e) - }, - Ok(_) | Err(_) => {} + if config.is_dir() { + println!("Create specific config file for module (using ambassade hide)? [y/N]?"); + + match io::stdin().read_line(&mut input) { + Ok(_) if input.as_str() == "y\n" => { + let dep_name = String::from(config.file_name().unwrap().to_str().unwrap()); + match super::dep_config::init(dep_name) { + Ok(_) => {}, + Err(e) => println!("Module initialization failed. Details: {}", e) + } + }, + Ok(_) | Err(_) => {} + } + } else { + panic!("Path does not exist!"); } } } diff --git a/src/backend/internal/mod.rs b/src/backend/internal/mod.rs index 1eada8d..c4b3e02 100644 --- a/src/backend/internal/mod.rs +++ b/src/backend/internal/mod.rs @@ -1 +1,2 @@ pub mod paralellism; +pub mod postmortem; diff --git a/src/backend/internal/postmortem.rs b/src/backend/internal/postmortem.rs new file mode 100644 index 0000000..5ccf636 --- /dev/null +++ b/src/backend/internal/postmortem.rs @@ -0,0 +1,19 @@ +extern crate ambassade_debug as dbg; + +pub struct DefaultSubmitMethod {} + +impl dbg::debug::SubmitMethod for DefaultSubmitMethod { + fn submit(&self, _info: &dbg::debug::DebugInfo) -> bool { + true + } + + fn submission_succeeded(&self, info: &dbg::debug::DebugInfo) { + println!(""); + println!("Please submit the information below to the repository or to a mirror:"); + println!("https://pagure.io/Ambassade/new_issue"); + println!("https://github.com/kapstok/Ambassade/issues/new"); + println!(""); + println!(""); + println!("{}", info); + } +} diff --git a/src/backend/system.rs b/src/backend/system.rs index 5d2efd3..f55277c 100644 --- a/src/backend/system.rs +++ b/src/backend/system.rs @@ -1,3 +1,5 @@ +extern crate ambassade_debug as dbg; + pub enum OS { All, Linux, @@ -21,3 +23,8 @@ impl OS { OS::Windows } } + + +pub fn watch() { + dbg::watch(super::internal::postmortem::DefaultSubmitMethod{}); +} diff --git a/src/main.rs b/src/main.rs index 038c3be..edd26f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,8 @@ mod shell; mod parser; fn main() { + backend::system::watch(); + match backend::filesystem::get_current_project_root() { Some(_) => println!("You are in a project."), None => println!("You are not in a project.")