<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Fri, 24 May 2013 03:09:11 GMT</pubDate>
	<lastBuildDate>Fri, 24 May 2013 03:09:11 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>7</c9:totalResults>
	<c9:pageCount>-7</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
		<description><![CDATA[<p>Quick and easy&nbsp;&quot;MSH style&quot; console&nbsp;input parameter parser with many features.&nbsp; Super simple to use.&nbsp; A single line of code will parse any amount of complicated parameters into the types you defined in the Data class.&nbsp;Also supports multiple&nbsp;Command &quot;Sets&quot;.
 Will convert and verify the strings into the types defined&nbsp;in the public fields and/or properties of the attributed&nbsp;Data class.<br>
<br>
Example:<br>
--------<br>
//InArgs is the Data object defining the parameters.<br>
//args is&nbsp;from&nbsp;Main(string[] args).<br>
Parameters parms = Parameters.CreateParameters(new InArgs(), args);<br>
<br>
Summary of features:<br>
--------------------------<br>
- Supports named parameters and position parameters.<br>
- Parcial names.&nbsp; &quot;-Name&quot; is same as &quot;-n&quot; or &quot;-na&quot;.<br>
- Automaticly builds &quot;Usage&quot; and Detailed Help.<br>
- Supports all primitive types *and Arrays of those types.&nbsp; Will also support any type that has a type converter&nbsp;to convert from a string.<br>
- Standardizes on &quot;-&quot; (not &quot;/&quot;) for&nbsp;parm names.<br>
- Parameter/values&nbsp;can be delimited by colon or space.&nbsp; Example: &quot;-name xxx&quot; or &quot;-name:xxx&quot;<br>
- Reserved parameters --, -?, -??, -h, -help, -ver, -version.<br>
- Mandatory parameters.<br>
- Prompt user with your prompt string if Mandatory parameter not given.<br>
<br>
A simple app with two optional parameters my look like:<br>
// InputArgsSimple.cs - Defines the expected parms, validations and help<br>
using System;<br>
using CmdParser;</p>
<p>namespace MyConsoleApp<br>
{<br>
&nbsp;/// &lt;summary&gt;<br>
&nbsp;/// InputArgsSimple.cs <br>
&nbsp;/// Defines the parameters we expect at the command line.<br>
&nbsp;/// Here is a simple class that define two optional parameters.<br>
&nbsp;/// First is a bool named Flag and second is a string named Name.<br>
&nbsp;/// The command line to set these fields could be:<br>
&nbsp;/// MyCmd -Flag -Name John<br>
&nbsp;/// MyCmd -Fl:true -Nam:John<br>
&nbsp;/// MyCmd -n John -f:F<br>
&nbsp;/// <br>
&nbsp;/// Note: When using Named parameters, the order is not important.<br>
&nbsp;/// We can also seperate the parm name from the value using a space or &quot;:&quot;.<br>
&nbsp;/// If a parameter is not given, the default value after construction is the<br>
&nbsp;/// value (i.e. not changed.)&nbsp; Only need to supply enouph chars in parm names<br>
&nbsp;/// to disambiguate from other parms.<br>
&nbsp;/// &lt;/summary&gt;<br>
&nbsp;[CmdHelp(&quot;Simple console app.&quot;, &quot;This is a simple console app to demo CmdParser.&quot;, &quot;<a target="_blank" href="http://www.mysite.com">www.mysite.com</a>&quot;, &quot;Copyright (c) 2005 MyOrg&quot;, null)]<br>
&nbsp;public class InputArgsSimple<br>
&nbsp;{<br>
&nbsp;&nbsp;[ParameterHelp(&quot;Starts app in windows mode.&quot;, &quot;Start the program in windows mode.&quot;)]<br>
&nbsp;&nbsp;public bool W;</p>
<p>&nbsp;&nbsp;[ParameterHelp(&quot;Name of user to find.&quot;, &quot;The name of the user to find.&quot;)]<br>
&nbsp;&nbsp;public string Name;<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;public InputArgsSimple()<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;}<br>
&nbsp;}<br>
}</p>
<p>// Main console class.<br>
using System;<br>
using CmdParser;<br>
using System.Reflection;<br>
using System.Collections;</p>
<p>namespace MyConsoleApp<br>
{<br>
&nbsp;class Class1<br>
&nbsp;{<br>
&nbsp;&nbsp;/// &lt;summary&gt;<br>
&nbsp;&nbsp;/// The main entry point for the application.<br>
&nbsp;&nbsp;/// &lt;/summary&gt;<br>
&nbsp;&nbsp;[STAThread]<br>
&nbsp;&nbsp;static void Main(string[] args)<br>
&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;InputArgsSimple inArgs = new InputArgsSimple();<br>
&nbsp;&nbsp;&nbsp;try<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;Parameters parms = Parameters.CreateParameters(inArgs, args);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;if ( parms.IsHelpNeeded )<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string helpString = &quot;&quot;;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch(parms.HelpChars)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;?&quot;:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helpString = parms.GetUsageString(Assembly.GetExecutingAssembly());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;\nUsage:&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(helpString);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Note: For detailed help, use -??, -h, or -help.&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;h&quot;:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;help&quot;:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;??&quot;:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helpString = parms.GetDetailedHelp(Assembly.GetExecutingAssembly());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(helpString);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br>
&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;if ( parms.IsVersionNeeded )<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Assembly assem = Assembly.GetExecutingAssembly();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string ver = assem.GetName().Version.ToString();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Version: &quot; &#43; ver);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br>
&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;if ( parms.BeenSetCount == 0 )<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// No parameters set at commandline, so display help.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// This could mean something else to your program.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string helpString = parms.GetUsageString(Assembly.GetExecutingAssembly());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;\nUsage:&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(helpString);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;Note: For detailed help, use -??, -h, or -help.&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br>
&nbsp;&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;// Just testing, so show the parms we set.<br>
&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;\n\nParms:&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;ParameterSet pSet = parms.ActiveSet;<br>
&nbsp;&nbsp;&nbsp;&nbsp;foreach(Parameter p in pSet.Parameters)<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string val = (p.Value == null) ? &quot;Null&quot; : p.Value.ToString();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(&quot;{0}: {1}&quot;, p.Name, val);<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;catch(Exception ex)<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(ex.Message);<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;}<br>
&nbsp;}<br>
}<br>
<br>
As we defined some help, we can get automatic Usage and Help.&nbsp; Usage looks like so:<br>
V:\MyConsoleApp\bin\Debug&gt;myconsoleapp -?<br>
<br>
Usage:<br>
MyConsoleApp [-W boolean] [-Name string]</p>
<p>Parameters:<br>
W&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Starts app in windows mode.<br>
Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Name of user to find.</p>
<p>Note: For detailed help, use -??, -h, or -help.<br>
<br>
<br>
Detailed help would look like:<br>
V:\MyConsoleApp\bin\Debug&gt;myconsoleapp -??</p>
<p>MyConsoleApp Help<br>
======================================================================<br>
Copyright (c) 2005 MyOrg<br>
Web Site: <a target="_blank" href="http://www.mysite.com">www.mysite.com</a><br>
Version : 1.0.1920.24820<br>
This is a simple console app to demo CmdParser.</p>
<p>Parameters<br>
----------------------------------------------------------------------<br>
-W<br>
[Boolean]<br>
[Mappings=(Default:-1)]<br>
Start the program in windows mode.</p>
<p>-Name<br>
[String]<br>
[Mappings=(Default:-1)]<br>
<br>
Naturally, you could build your own help if required.<br>
Would really&nbsp;appreciate any feedback on issues, new features, likes/dislikes, etc.<br>
<br>
Version History<br>
-------------------<br>
1/9/2005 - v1.5 Updated to include SendMail sample client project using the CmdParser library. &nbsp;Added CmdParser.Doc.<br>
<br>
<br>
--William Stacey[MVP]</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/52952#52952</link>
		<pubDate>Mon, 04 Apr 2005 17:26:50 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/52952#52952</guid>
		<dc:creator>William Stacey</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/staceyw/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
		<description><![CDATA[<p><div>Not to complain... but there are about a hundred of these already.&nbsp; The one I currently like that's simple, flexible, and lightweight is here:<br>
<br>
<a href="http://www.codeproject.com/csharp/command_line.asp">http://www.codeproject.com/csharp/command_line.asp</a><br>
<br>
I'm sure this is a lot of fun to build and a great learing exercise but codeproject.com has a few dozen more if that didn't do the job.<br>
<br>
Good luck with yours.<br>
</div></p>]]></description>
		<link>http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/769c03f9466d4c96ac299dea01031e4d#769c03f9466d4c96ac299dea01031e4d</link>
		<pubDate>Mon, 04 Apr 2005 17:50:08 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/769c03f9466d4c96ac299dea01031e4d#769c03f9466d4c96ac299dea01031e4d</guid>
		<dc:creator>databyte</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/databyte/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
		<description><![CDATA[<p>Thanks databyte.&nbsp; But you will need to look closer.&nbsp; This is nothing like those other parsers.&nbsp; This is modeled after the MSH (i.e. Monad) parser.&nbsp; Can handle all primitive types, arrays of those types, any other type you can define a converter for.&nbsp; It
 also has integrated Detailed help and Usage help and a ton of validation such as:<br>
CmdHelp (Defines help for the whole command.)<br>
DefaultSet (Defines the default set when more sets match.)<br>
Parameter (base attribute)<br>
ParameterHelp (Defines help for the parm.)<br>
ParsingMandatoryParameter (Parm is required)<br>
ParsingParameterDeclaration<br>
ParsingParameterMapping (Maps parm to set name and position)<br>
ParsingPromptString (Prompt for input)<br>
ParsingVariableLengthParameterList (var list)<br>
SwitchParameter (a bool)<br>
ValidationCount (Array min/max count)<br>
ValidationLength (string min/max len)<br>
ValidationPattern (Regex pattern)<br>
ValidationRange (Object min/max range)<br>
ValidationSet (Set of strings that are valid.)<br>
<br>
You also get Parameter Sets, variable length parameter lists, Input Prompt, mandatory checks, various validations, etc.&nbsp; In effect, allows you to Overload your command line parms into &quot;Sets&quot; and the engine figures out which set to use or throws proper error.&nbsp;
 It also works with any combination of Named or Position parameters and figures out which set to use if possible.&nbsp; You also get &quot;Parcial&quot; name support.&nbsp; So &quot;-n:hello&quot; is the same as &quot;-Name hello&quot; or even&nbsp;&quot;-na xyz&quot; if we can disabiguate the name from other parms.&nbsp;
 Other helpful things I need to write about.&nbsp;&nbsp;Thanks.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/6ff1c9be5d5b4bad92949dea01031e7a#6ff1c9be5d5b4bad92949dea01031e7a</link>
		<pubDate>Mon, 04 Apr 2005 19:07:09 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/6ff1c9be5d5b4bad92949dea01031e7a#6ff1c9be5d5b4bad92949dea01031e7a</guid>
		<dc:creator>William Stacey</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/staceyw/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
		<description><![CDATA[<p>Excellent !<br>
<br>
Thank you for sharing.<br>
<br>
Steven J. Ackerman, Consultant<br>
ACS, Sarasota, FL<br>
<a href="http://www.acscontrol.com">http://www.acscontrol.com</a><br>
<a href="http://spaces.msn.com/members/sjackerman">http://spaces.msn.com/members/sjackerman</a><br>
&nbsp;</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/c52b09c595b849c5963e9dea01031ea3#c52b09c595b849c5963e9dea01031ea3</link>
		<pubDate>Mon, 04 Apr 2005 20:45:24 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/c52b09c595b849c5963e9dea01031ea3#c52b09c595b849c5963e9dea01031ea3</guid>
		<dc:creator>Steven J Ackerman</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Steven J Ackerman/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
		<description><![CDATA[<p>Hi William, <br>
<br>
It will be very helpfull to show some examples how to use it.<br>
<br>
Thanks,<br>
Martin</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/8bdd501e1bdb4186844c9dea01031ee4#8bdd501e1bdb4186844c9dea01031ee4</link>
		<pubDate>Wed, 06 Apr 2005 00:44:23 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/8bdd501e1bdb4186844c9dea01031ee4#8bdd501e1bdb4186844c9dea01031ee4</guid>
		<dc:creator>Martin Kulov</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Martin Kulov/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
		<description><![CDATA[<p>Added sample project (SendMail) using the lib.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/3bbb0b20edbe4d34bf679dea01031f0d#3bbb0b20edbe4d34bf679dea01031f0d</link>
		<pubDate>Mon, 09 Jan 2006 23:22:19 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/3bbb0b20edbe4d34bf679dea01031f0d#3bbb0b20edbe4d34bf679dea01031f0d</guid>
		<dc:creator>William Stacey</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/staceyw/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>The Sandbox - MSH-Style Command Line Parser for Console apps. V1.5</title>
		<description><![CDATA[<p>Great library William, definitely my favourite command line parser. Any chance you have any unit tests for it?</p>]]></description>
		<link>http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/4a01d734beec45a5b9e99dea01031f4d#4a01d734beec45a5b9e99dea01031f4d</link>
		<pubDate>Mon, 16 Nov 2009 00:47:28 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/Sandbox/MSH-Style-Command-Line-Parser-for-Console-apps-V15/4a01d734beec45a5b9e99dea01031f4d#4a01d734beec45a5b9e99dea01031f4d</guid>
		<dc:creator>Steve</dc:creator>
		<slash:comments>7</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/stevenpack/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>