Tyrrrz / CliWrap

Library for running command-line processes
MIT License
4.39k stars 268 forks source link

Missing WithTargetFilePath() method #98

Closed 8 closed 3 years ago

8 commented 3 years ago

Hi,

I was looking for a WithTargetFilePath() method, but I didn't find any.

e.g. You have a command Command and now you want to wrap in another shell, e.g. run it using wsl. On the shell, I just need to prepend wsl before the command The same goes for different versions of executables that differ only by name.

Did I miss anything / Is there another some design reason why this is not supported?

Thank you!

Take care, Martin

Tyrrrz commented 3 years ago

Hi.

The With... methods were added as a more convenient way to configure optional parameters. The target file path is the only parameter which is not optional, so there is no With... method for it. That's pretty much the only reason.

I could see the benefit of adding it for the use case you explained, but wouldn't it be easier to do something like this?

public Command GetMyCommand(string shell, string command) =>
    Cli.Wrap(shell).WithArguments(new[]{"-c", command});