openssh icon indicating copy to clipboard operation
openssh copied to clipboard

Add `.with_args` feature to rust library

Open ActuallyHappening opened this issue 7 months ago • 3 comments

This features exists in bossy::Command here: https://docs.rs/bossy/latest/bossy/struct.Command.html#method.with_args

It is quite useful, allowing you to write this:

let kill_cmd = session.command("/root/.cargo/bin/nu").withargs([
  "-c",
  r##"ps | filter {|ps| $ps.name == "surreal"} | get pid | each {|pid| kill $pid }"##,
]);

... instead of this:

let mut kill_cmd = session.command("/root/.cargo/bin/nu");
kill_cmd.args([
  "-c",
  r##"ps | filter {|ps| $ps.name == "surreal"} | get pid | each {|pid| kill $pid }"##,
]);

This saves using the mut keyword and a new line, and can even be implemented trivially using an extension trait

ActuallyHappening avatar Jul 02 '24 04:07 ActuallyHappening