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

Can cmd_lib cooperate with Command? #69

Open
jesHrz opened this issue Sep 22, 2024 · 0 comments
Open

Can cmd_lib cooperate with Command? #69

jesHrz opened this issue Sep 22, 2024 · 0 comments

Comments

@jesHrz
Copy link

jesHrz commented Sep 22, 2024

I am not very familiar with Rust.

Though cmd_lib can pass a vector to run_cmd!, the vector item must still be the same type, which is inconvenient.

For example, trying to pass arguments wich contains both literal &str and integer u64 needs to be like:

let a = 999999u32;
let b = 88888u64;
let args = vec!("-a".to_string(), a.to_string(), "-b".to_string(), b.to_string());
run_cmd!(some_cmd $[args]);

all items must be converted to String. Using Command can be more easy:

let mut cmd = Command::new(some_cmd);
cmd.arg("-a").arg(a.to_string());
cmd.arg("-b").arg(b.to_string());
let output = cmd.output();

this example can easily construct the command and corresponding arguments, but it is hard to control the subprocess, while cmd_lib is easy to run the command but hard to construct it.

I'm wondering, how can I use Command to construct commands and use cmd_lib to launch the command?
If the answer is no, when cmd_lib can cooperate with Command, would it be better for both command construction and controlling?

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

No branches or pull requests

1 participant