From badfad22bee598122d9d4ed24d47825054df11cc Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Wed, 10 Oct 2018 00:10:23 +0000 Subject: [PATCH] Read Cargo.toml from target dir When running `crossgen` on a directory with a missing `Cargo.toml` it would panic with an error message. Debugging what happend, I've found it failed to find a `Cargo.toml` file, as it don't exist. To my surprise, when I've cloned the repo and tried to reproduce using `cargo run -- ~/path/to/my-dir`, there was no panic! This happened because the `Cargo.toml` was found on `crossgen` repo, not on my targe repo, as expected. This commit changes the location of the manifest file to use the directory parsed from the arguments. Signed-off-by: Bruno Tavares --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index dc8c6a7..8b4dd59 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ use cargo_toml::TomlManifest; use crossgen::Cli; use exitfailure::ExitFailure; use std::fs::read; +use std::path::PathBuf; use structopt::StructOpt; fn main() -> Result<(), ExitFailure> { @@ -23,11 +24,11 @@ fn main() -> Result<(), ExitFailure> { let args = Cli::from_args(); args.log(env!("CARGO_PKG_NAME"))?; - let dir = args.dir()?; + let dir: PathBuf = args.dir()?; let name = args.name()?; let lib = args.lib(); - let manifest = TomlManifest::from_slice(&read("Cargo.toml")?)?; + let manifest = TomlManifest::from_slice(&read(dir.join("Cargo.toml"))?)?; let repo = manifest .package .repository