Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oleksiyrudenko/commandlineparser
https://github.com/oleksiyrudenko/commandlineparser
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/oleksiyrudenko/commandlineparser
- Owner: OleksiyRudenko
- Created: 2015-08-29T14:19:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-17T11:19:52.000Z (over 9 years ago)
- Last Synced: 2024-10-29T20:19:08.739Z (3 months ago)
- Language: C#
- Size: 191 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C# Command Line Parser
Command Line Parser is a test application submitted to [Kottans](http://kottans.org/) to apply for a C# course.
The application parses console command line arguments producing predictable results according to an assignment.## Requirements
To build the application Visual Studio 2010+ is required.## Features
Command line arguments:
* `-k key value key value...` - prints pairs of key and value; `` replaces absent value
* `-print message to print` - prints given message
* `-ping` - beeps and prints "Pinging..." NB! No actual pinging is effected whatever it might mean except the behaviour described
* `-d [dateFormat]` - prints current date using given format; default format is yyyy-MM-dd.
* `-exit` - terminates application immediately.Use `/?`, `-help` or `/help` command-line argument to get help from the application in console.
Commands are executed in order of their appearance except for `/?`, `/help` and `-help`, which are ignored once help output occured.## Compilation
Open solution with Visual Studio and press F7 to build the application.## Tests
1. Open solution root folder in Explorer.
2. Launch `CommandLineParserTest.bat`You will see app behaviour run with various command-line arguments as well as error handling.
## Extending Features
For e.g. you want to implement new command, say, `-foo`.
Add new class to the solution.
Class name should start with `Cmd` followed by command name (excluding leading dash) with first letter capitalized.
This class should extend abstract class Cmd and implement two methods:1. `Usage()`, which returns String containing command usage description.
2. `ToString()`, which returns String containing arguments processing result.Example:
```
class CmdFoo : Cmd
{
static public String Usage()
{
return "-foo argument anotherArgument yetAnother Argument";
}
override public String ToString()
{
// process arguments, contained in the field arguments of Queue type
return (arguments.Count > 0) ? arguments.Dequeue() : ""; // or whatever you want
}
}
```
Amend `CommandLineParserTest.bat` as appropriate to test your command.## Usage
Well, I doubt one can make any real use from this application. But, please, feel free playing around.
`CommandLineParserTest.bat` is a good source of ideas for that. Amend it to see how various command-line arguments affect application output.## Author
Oleksiy Rudenko [email protected]Aug 29, 2015