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

Ability to get the Command from CargoBuild #77

Open
ronnychevalier opened this issue Dec 19, 2023 · 3 comments
Open

Ability to get the Command from CargoBuild #77

ronnychevalier opened this issue Dec 19, 2023 · 3 comments
Labels
enhancement Improve the expected

Comments

@ronnychevalier
Copy link

The API of CargoBuild does not allow us to get the inner Command it is building.
We can only run the Command with exec().

Having access to a method like into_command() (or something similar) can be useful if another crate requires a &mut Command to do something.

@epage
Copy link
Contributor

epage commented Dec 19, 2023

So if I understand, the intention is to use escargot API to help generate the flags for cargo build but you wouldn't then want the other half, of parsing the output?

@ronnychevalier
Copy link
Author

So if I understand, the intention is to use escargot API to help generate the flags for cargo build but you wouldn't then want the other half, of parsing the output?

No, I would still use the parsing of the output.

For example, with the following code:

let cargo = CargoBuild::new().manifest_path(...).arg(...);
let mut command = cargo.into_command();

// Function that modifies `Command` to add args or env variables.
other_crate::Struct::function(&mut command);

let r = CommandMessages::with_command(command);

The only missing piece is something that returns the inner Command from CargoBuild.
We could even have another function that just returns the &mut Command:

let cargo = CargoBuild::new().manifest_path(...).arg(...);

// Function that modifies `Command` to add args or env variables.
other_crate::Struct::function(cargo.command_mut());

let r = cargo.exec();

@epage
Copy link
Contributor

epage commented Dec 19, 2023

Thanks for the further explanation. Feel free to put up a PR for into_command for all of the command-owning types.

@epage epage added the enhancement Improve the expected label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

2 participants