ECLP {Easy Command Line Parser}.
03. Parse
Parse function can use 2 ways of parsing, either using Regex or a Side by side words check algorithm.
Using Regex
Is the default way of parsing when you Parse() function without specifying usingRegex bool parameter inside the constructor because it have a true value by default
using System.Windows.Forms;
using The_Morpher;
namespace ConsoleApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string commandLine = "start 5 3.6 true T --verbose --noClip --showStats -p driver=steave -p age=30 -c players=steave|john|clark -xc players=steave:21|john:15|clark:30";
ECLP eCLP = new ECLP(commandLine);
CommandResult cr = eCLP.Parse();
// or
// CommandResult cr = eCLP.Parse(true);
// same
Console.ReadKey();
}
}
}
Side by side words check
Is another way of parsing more pertinant but use a long code behind the scenes.
using System;
using System.Linq;
using The_Morpher;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
string commandLine = "start 5 3,6 true T --verbose --noClip --showStats -p driver=steave -p age=30 -c players=steave|john|clark -xc players=steave:21|john:15|clark:30";
ECLP eCLP = new ECLP(commandLine);
CommandResult result = eCLP.Parse(false);
}
}
}
The way there's 2 ways of parsing is because Regex is not all the time used by some third party as it was the case for me.
I used ECLP in a third party application that use its own mono modified assembly which don't use regex at all and then i need to find another way to handle parsing.
Regex can sometime can't match result in some weird scenarios as maybe it need to improve regex pattern which is not my best.
Want me to dev an app for you ? dont hesitate to contact me.
Are you looking for a coder/teammate for your project ? Let's give it a try.
Have a proposal for me ? we can discuss about it.
You want to buy me a coffe ? m.elharfi@gmail.com