madelson/MedallionShell

Overriding ToString to output exact process and arguments on Command

Closed this issue · 3 comments

Hi, first of thanks for the great library, already saved me a lot of time for automating lots of small tasks.

I'm however finding for debugging purposes wanting to output the started process including the given arguments when I do a Command.Run()..

I could obviously do it myself, but I think it would make sense if the ToString on Command is overridden to return the actual command that'll be executed. What do you think about this idea, or is there already another way to achieve the same result?

So if I do;

var cmd = Command.Run("path_to_grep", "some REGEX");
cmd.ToString(); // --> This would equal "path_to_grep some REGEX"

It should obviously use the CommandLineSyntax if one is configured in the options.

Thanks again.
Stephan

Meanwhile I've been investigating some more, and figured out I can actually do cmd.Process.ProcessName + " " + cmd.Process.StartInfo.Arguments. However for that to work I'd have to have configured the options DisposeOnExit as false: options => options.DisposeOnExit(false).

I guess it would be better to store the StartInfo state in a field, so it can be used even after the process has run and been disposed?

Thanks @Stephanvs for your interest in the library. I agree that this is a good build and will simplify debugging. I will put this in the next release.