-
Notifications
You must be signed in to change notification settings - Fork 40
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
Allow serializing a constructed Command #212
Comments
I'd be open to a PR that added the same getters that |
Ah yes I was just looking at those when I made the PR, so I can implement these wrappers: pub fn get_args(&self) -> CommandArgs<'_> {
}
pub fn get_current_dir(&self) -> Option<&Path> {
}
pub fn get_envs(&self) -> CommandEnvs<'_> {
}
pub fn get_program(&self) -> &OsStr {
} and introduce this (or under another name, with the same signature?) pub fn get_cmd(&self) -> process::Command {
} |
I scoped it to just what |
@epage I realised I don't actually need any of those getters as this achieves everything I need format!("{:?}", process::Command::from(cmd)); But since you were receptive I tried raising the PR anyway. If reviewing and giving feedback is more hassle than it's worth though feel free to close it, as my use case is covered. |
I'm trying to convert some tests to use
rexpect::spawn
to work around some issues with tty handling, but I'm having trouble re-using all my existingassert_cmd
as I can't construct a single string with the constructed command as thecmd
field onCommand
is private.With the following code
I'd like to be able to get a string like
Calling
format!("{:?}", cmd)
prints the following, withcmd
in the format I'd like, but also stdin/stdout etcI'm not sure what the most rust-y solution would be, but it would help if either:
cmd
was marked publiccmd
in a serialized formCommand
to get the underlying cmd, at which point I think I can serialize it myselfI'm happy to attempt a PR if an option from the above is chosen / another suggested
The text was updated successfully, but these errors were encountered: