5

テキストエディタをポップアップせずに、コマンドラインでワークスペースを編集/作成したいのですが。ドキュメントには、標準入力を使用するために-iフラグを使用すると書かれています。この使用法の構文/形式は何ですか?

ファイルの受け渡しは正しく機能します:p4 client -i <fileDefiningTheWorkspace.txt

ワークスペースを定義する実際の文字列を渡すことは機能しません:p4 client -i "Root:C:\ The \ Root \ r \ nOptions:noallwrite noclobber....."

何か案は?ありがとう!

4

2 に答える 2

6

そのような文字列を入力するだけでは、標準入力には渡されません。ファイルを渡す最初の例のように、いくつかの入力を指示する必要があります。

コマンドラインの一部として文字列が本当に必要な場合は、echoなどを使用して適切なテキストをパイプする必要があります。ただし、echoは改行をサポートしていないため、各行を個別にエコーする必要があります。

(エコーライン1&エコーライン2&エコーライン3)| p4クライアント-i

それはかなりすぐにかなり醜くなるでしょう。

あなたは本当にc#からこれを行う方法を知りたいように思われるので、コマンドラインプロセスを起動して入力を供給する非常に大まかな準備ができた例を次に示します。

        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);
于 2012-12-11T20:24:08.403 に答える
1

私の場合、その問題に対処した後、解決策は次のようになります。

P4Process.StartInfo.Arguments="client -i"
StreamWriter myStreamWriter = P4Process.StandardInput;
                String inputText = File.ReadAllText(@"C:\Program Files\Perforce\clientSpec.txt");
                myStreamWriter.Write(inputText);
                P4Process.StandardInput.Close();                  

                P4Process.BeginOutputReadLine();
                P4Process.BeginErrorReadLine();

                P4Process.WaitForExit();

私にとってそれは同じでした:

p4 client - i < clientSpec.txt
于 2016-01-19T10:54:57.683 に答える