Skip to content

Commit

Permalink
Read Cargo.toml from target dir
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bltavares committed Oct 10, 2018
1 parent 48fa6fc commit badfad2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ 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> {
setup_panic!();
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
Expand Down

0 comments on commit badfad2

Please sign in to comment.