Inside Command Line Argument Parser – Automatic Help
Another feature that Cinchoo framework provides you is that, it automatically creates Usage help text.
1. Add a reference to Cinchoo.Core.dll
2. Namespace: Cinchoo.Core.Shell
For a sample Command Line object below,
[ChoCommandLineArgObject(ApplicationName = "Hello World", Copyright = "Copyright (c) Cinchoo Inc.")] public class MyCommandLineArgObject : ChoCommandLineArgObject { [ChoCommandLineArg("D", DefaultValue = "%NOW%", Description = "Business Date.", ShortName = "Today")] public DateTime Today { get; set; } [ChoCommandLineArg("N", DefaultValue = "{100+100}", Description = "No of spaces for a TAB.")] public int Count { get; set; } [ChoCommandLineArg("I", DefaultValue = false, FallbackValue = true, Description = "Include Sub directory.")] public bool IncludeSubDir { get; set; } [ChoCommandLineArg("O", IsRequired = true, Description = "Output Directory.")] public string OutFolder { get; set; } }
If the application containing above type executed with the below command line arguments
/help or /? or /h
When creating instance of MyCommandLineArgObject as below,
MyCommandLineArgObject commandLineArgObject = new MyCommandLineArgObject(); Console.WriteLine(commandLineArgObject.ToString());
And run the application, the commandLineArgObject will display the usage as below
Hello World [Version 1.0.0.0] Copyright (c) Cinchoo Inc. Cinchoo.Core.CommandLineArgs.Test.exe -D:Today -N:<int> -I:{True|False} -O:[<string>] Where -D Business Date. -N No of spaces for a TAB. -I Include Sub directory. -O Output Directory.