Skip to content

Can cmd_lib cooperate with Command? #69

Open
@jesHrz

Description

@jesHrz

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions