From a4b7a4d909d42a1da1974e4833c6187bf506e8f7 Mon Sep 17 00:00:00 2001 From: godsfryingpan Date: Mon, 23 Mar 2026 16:22:47 -0500 Subject: [PATCH 1/4] Fix clippy --- src/app.rs | 93 ++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/src/app.rs b/src/app.rs index 8d251f4..a6028ab 100644 --- a/src/app.rs +++ b/src/app.rs @@ -186,7 +186,7 @@ impl App { fn add_package(package: &str) -> std::io::Result<()> { let status = Command::new("pkg-config") .arg("--exists") - .arg(&package) + .arg(package) .status() .map_err(|_| { std::io::Error::new( @@ -276,7 +276,7 @@ fn gen_compile_commands(mode: &Option) -> std::io::Result<()> { .collect(); let json = serde_json::to_string_pretty(&entries) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{e}")))?; + .map_err(|e| std::io::Error::other(format!("{e}")))?; std::fs::write("compile_commands.json", json)?; @@ -381,45 +381,43 @@ fn build(mode: &Option, force_recompile: bool) -> std::io::Result<()> { let mut extra_compile_flags: Vec = Vec::new(); let mut extra_link_flags: Vec = Vec::new(); - if let Some(deps) = &conf.dependencies { - if !deps.is_empty() { - let cflags = Command::new("pkg-config") - .arg("--cflags") - .args(deps) - .output() - .map_err(|_| { - std::io::Error::new(std::io::ErrorKind::NotFound, "pkg-config not found") - })?; - if !cflags.status.success() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "pkg-config --cflags failed - is the package installed?", - )); - } - - let libs = Command::new("pkg-config") - .arg("--libs") - .args(deps) - .output() - .map_err(|_| { - std::io::Error::new(std::io::ErrorKind::NotFound, "pkg-config not found") - })?; - if !libs.status.success() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "pkg-config --libs failed - is the pacakge installed?", - )); - } - - extra_compile_flags = String::from_utf8_lossy(&cflags.stdout) - .split_whitespace() - .map(str::to_owned) - .collect(); - extra_link_flags = String::from_utf8_lossy(&libs.stdout) - .split_whitespace() - .map(str::to_owned) - .collect(); + if let Some(deps) = &conf.dependencies + && !deps.is_empty() + { + let cflags = Command::new("pkg-config") + .arg("--cflags") + .args(deps) + .output() + .map_err(|_| { + std::io::Error::new(std::io::ErrorKind::NotFound, "pkg-config not found") + })?; + if !cflags.status.success() { + return Err(std::io::Error::other( + "pkg-config --cflags failed - is the package installed?", + )); } + + let libs = Command::new("pkg-config") + .arg("--libs") + .args(deps) + .output() + .map_err(|_| { + std::io::Error::new(std::io::ErrorKind::NotFound, "pkg-config not found") + })?; + if !libs.status.success() { + return Err(std::io::Error::other( + "pkg-config --libs failed - is the pacakge installed?", + )); + } + + extra_compile_flags = String::from_utf8_lossy(&cflags.stdout) + .split_whitespace() + .map(str::to_owned) + .collect(); + extra_link_flags = String::from_utf8_lossy(&libs.stdout) + .split_whitespace() + .map(str::to_owned) + .collect(); } let source_files: Vec = glob("src/*.c") @@ -455,10 +453,10 @@ fn build(mode: &Option, force_recompile: bool) -> std::io::Result<()> { .status()?; if !status.success() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - format!("failed to compile {}", src.display()), - )); + return Err(std::io::Error::other(format!( + "failed to compile {}", + src.display() + ))); } std::fs::write(&hash_path, &hash)?; @@ -493,15 +491,12 @@ fn build(mode: &Option, force_recompile: bool) -> std::io::Result<()> { .status()?; if !status.success() { - return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "linking failed", - )); + return Err(std::io::Error::other("linking failed")); } let stop = start.elapsed(); - gen_compile_commands(&mode)?; + gen_compile_commands(mode)?; println!( " {} '{}' profile for project '{}' in {:.2}s", -- 2.49.1 From 99722302a219b4d8ea0718e8be852483523b0a3a Mon Sep 17 00:00:00 2001 From: godsfryingpan Date: Mon, 23 Mar 2026 16:25:30 -0500 Subject: [PATCH 2/4] first attempt at fixing issue --- src/app.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index a6028ab..161198c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -95,7 +95,9 @@ impl App { } } Subcommand::Init => { - if let Err(e) = create_project(".") { + let root = std::env::current_dir().expect("the current working directory"); + let path = root.file_name().expect("some file name"); + if let Err(e) = create_project(path.to_string_lossy().to_string()) { eprintln!("Error initializing project: {e}"); std::process::exit(1); } -- 2.49.1 From 8039f5e778bed57114bec41f7561db1c43212ebf Mon Sep 17 00:00:00 2001 From: godsfryingpan Date: Mon, 23 Mar 2026 16:26:30 -0500 Subject: [PATCH 3/4] Revert "first attempt at fixing issue" This reverts commit 99722302a219b4d8ea0718e8be852483523b0a3a. --- src/app.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app.rs b/src/app.rs index 161198c..a6028ab 100644 --- a/src/app.rs +++ b/src/app.rs @@ -95,9 +95,7 @@ impl App { } } Subcommand::Init => { - let root = std::env::current_dir().expect("the current working directory"); - let path = root.file_name().expect("some file name"); - if let Err(e) = create_project(path.to_string_lossy().to_string()) { + if let Err(e) = create_project(".") { eprintln!("Error initializing project: {e}"); std::process::exit(1); } -- 2.49.1 From 1974ed90be0949da2f1ab1ae2226cfc3042ba12b Mon Sep 17 00:00:00 2001 From: godsfryingpan Date: Mon, 23 Mar 2026 16:29:33 -0500 Subject: [PATCH 4/4] second attempt --- src/app.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index a6028ab..e996456 100644 --- a/src/app.rs +++ b/src/app.rs @@ -330,7 +330,19 @@ fn create_project>(directory: P) -> std::io::Result<()> { std::fs::write("src/main.c", MAIN_C)?; std::fs::write(".gitignore", GITIGNORE)?; - let config = crate::config::Config::new(&pathdir.to_string_lossy()); + let lossy = pathdir.to_string_lossy(); + + let app_name = if lossy == "." { + let root = std::env::current_dir()?; + root.file_name() + .expect("a valid file name") + .to_string_lossy() + .to_string() + } else { + lossy.to_string() + }; + + let config = crate::config::Config::new(&app_name); let serial = toml::to_string_pretty(&config).expect("a valid TOML structure"); -- 2.49.1