Reputation: 469
I'm supposed to write a command line tool in C#. Problem is, I'm completely new to it and have to read up on a lot of stuff. The tool has to accept several parameters with a syntax I have no idea of what it does. It goes like this:
tool.exe \path\data.log /lastrun:file1.txt >file2.txt
The tool is supposed to output data on stdout, which is meant to be read again and possibly processed with further console commands. How can one reference the output?
I have practically no experience with command line tools. I would appreciate if anyone could either drop me some smart words I could look up, links or simply explains me what is going on here.
Upvotes: 0
Views: 364
Reputation: 8872
Outputting data on stdout is easy. Just write to the Console
class. If you want to read in you could use the static read methods on the console class as well, though depending on the type of data you are sending you may want to look into pipes. Here is another post Standard Input & Output in .NET asking the same question.
As far as console input format, like was mentioned, that's up to you!
Upvotes: 1
Reputation: 499392
You are the one to decide the format of the command line parameters (what you call "markup").
It is entirely up to you whether it is valid or not.
You need to parse the passed in arguments - see Main() and Command-Line Arguments (C# Programming Guide) on MSDN for details. Many people use a command line parsing library (there are many - search and find one you like, perhaps the one with the best documentation).
As for >
- I suggest you read about command redirection (article about XP, but still valid).
Upvotes: 5