Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read Cargo.toml from target dir #18

Merged
merged 1 commit into from
Oct 17, 2018

Conversation

bltavares
Copy link
Contributor

@bltavares bltavares commented Oct 10, 2018

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.

Choose one: is this a 🐛 bug fix, a 🙋 feature, or a 🔦 documentation change?
🐛

Checklist

  • tests pass
  • tests and/or benchmarks are included
  • documentation is changed or added

Context

Related issue while debugging: rust-cli/human-panic#30 (comment) and #16

Semver Changes

@bltavares bltavares force-pushed the read-cargo-from-dir branch from 57b7ce6 to badfad2 Compare October 10, 2018 00:20
src/main.rs Outdated
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()?;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely not. I thought I was doing type conversion from string to pathbuf, because I looked at the wrong property on cli.rs. I'll remove this.

@yoshuawuyts
Copy link
Owner

@bltavares this patch looks pretty good! -- ideally we could have some regression test for this too, but we don't have a test framework setup yet, so it might be a bit odd. Is this something you'd be okay with adding?

@bltavares
Copy link
Contributor Author

@yoshuawuyts I wouldn't be able to setup the testing harness soon enough, but I could help with that in a near future, if that is ok for you.

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]>
@bltavares bltavares force-pushed the read-cargo-from-dir branch from badfad2 to 7690cad Compare October 12, 2018 01:34
@yoshuawuyts yoshuawuyts merged commit 8532f83 into yoshuawuyts:master Oct 17, 2018
@bltavares bltavares deleted the read-cargo-from-dir branch October 17, 2018 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants