shokai / ConsoleLib.NET
params(args) parser for .NETFrameowrk3.5 and Mono2.0
Clone this repository (size: 251.1 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/shokai/consolelibnet/
| commit 13: | d127eb789a4b |
| parent 12: | 20deaec47cb8 |
| branch: | default |
add tests
Sho Hashimoto /
shokai
7 months ago
7 months ago
ConsoleLib.NET /
ConsoleLibSample
/
Program.cs
| r13:d127eb789a4b | 44 loc | 1.2 KB | embed / history / annotate / raw / |
|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Org.Shokai.Util.ConsoleLib;
namespace ConsoleLibSample
{
class Program
{
static void Main(string[] args)
{
ParamsParser pp = new ParamsParser(args);
pp.Bind("output", "o");
pp.Bind("input", "i");
Console.WriteLine("First: " + pp.First);
// switches (e.g. -l -d)
Console.Write("Switches: ");
foreach (string sw in pp.Switches)
{
Console.Write(sw + " ");
}
Console.WriteLine();
// parameters (e.g. -m "hello" -out "output.txt")
Console.WriteLine("Params: ");
foreach (string key in pp.Params.Keys)
{
Console.WriteLine(" "+key+"="+pp.Params[key]);
}
// raw args
Console.Write("ARGS: ");
foreach (string arg in pp.ARGS)
{
Console.Write(arg + ",");
}
Console.WriteLine();
}
}
}
|
