I'd like to edit/create a workspace on the command line without any text editor popping up. The docs say to use the -i flag to use Standard Input. What is the syntax / format of this usage?
Passing a file works correctly: p4 client -i < fileDefiningTheWorkspace.txt
Passing the actual string defining the workspace doesn't work: p4 client -i "Root: C:\The\Root\r\nOptions: noallwrite noclobber....."
Any ideas? Thanks!
Just entering a string like that won't pass it in standard-input. You need to direct some input, as with your first example of passing a file.
If you really need the string as part of a command line, you would need to use something like echo to pipe the appropriate text in. However echo doesn't support newlines, so you need to echo each line separately:
(echo line1 & echo line2 & echo line3) | p4 client -i
It'll get pretty ugly pretty quickly.
As you seem to be really wanting to know how to do this from c#, here's a very rough and ready example of firing up a command-line process and feeding it input:
ProcessStartInfo s_info = new ProcessStartInfo(@"sort.exe");
s_info.RedirectStandardInput = true;
s_info.RedirectStandardOutput = true;
s_info.UseShellExecute = false;
Process proc = new Process();
proc.StartInfo = s_info;
proc.Start();
proc.StandardInput.WriteLine("123");
proc.StandardInput.WriteLine("abc");
proc.StandardInput.WriteLine("456");
proc.StandardInput.Close();
String output = proc.StandardOutput.ReadToEnd();
System.Console.Write(output);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With