Created
March 16, 2017 09:55
-
-
Save dgg/1531d3d8fffedd0f2a197f311d85a87d to your computer and use it in GitHub Desktop.
not-last-console-LBiCliArguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *NotLastConsole_LBiCliArguments*>doer -help | |
| SYNTAX | |
| doer.exe something -Location <String> [-Awesome] [-Times <Int32>] | |
| Do something. | |
| doer.exe something-else -Locations <String[]> [-Awesome] | |
| Do something else. | |
| doer.exe -Help [-Detailed] [-Examples] [-Full] [-Parameters] | |
| Show help |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IRunnable | |
| { | |
| void Run(); | |
| } | |
| [ParameterSet("Something", HelpMessage = "Do something.", Command = "something")] | |
| public class Something : IRunnable | |
| { | |
| [Parameter(HelpMessage = "place where the something was done"), Required] | |
| public string Location { get; set; } | |
| [Parameter(HelpMessage = "number of times something was done")] | |
| [DefaultValue("1")] | |
| public int Times { get; set; } | |
| [Parameter(HelpMessage = "include if the something was awesome")] | |
| public Switch Awesome { get; set; } | |
| public virtual void Run() | |
| { | |
| var inner = new ADoerOfSomething(Console.Out); | |
| var options = new OptionsForSomething | |
| { | |
| Location = Location, | |
| Times = Times, | |
| Awesome = Awesome.IsPresent | |
| }; | |
| inner.Do(options); | |
| } | |
| } | |
| [ParameterSet("SomethingElse", Command = "something-else", HelpMessage = "Do something else.")] | |
| public class SomethingElse : IRunnable | |
| { | |
| [Parameter(HelpMessage = "places where the something else was done"), Required] | |
| public string[] Locations { get; set; } | |
| [Parameter(HelpMessage = "include if the something else was awesome")] | |
| public Switch Awesome { get; set; } | |
| public virtual void Run() | |
| { | |
| var inner = new ADoerOfSomethingElse(Console.Out); | |
| var options = new OptionsForSomethingElse | |
| { | |
| Locations = Locations, | |
| NotSoAwesome = !Awesome | |
| }; | |
| inner.Do(options); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var parser = new ArgumentParser<IRunnable>(typeof(Something), typeof(SomethingElse)); | |
| IRunnable runnable; | |
| if (parser.TryParse(args, out runnable)) | |
| { | |
| runnable.Run(); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *NotLastConsole_LBiCliArguments*>doer something | |
| Missing requried paramter: 'Location'. | |
| -Location <String> | |
| place where the something was done | |
| Required? True | |
| Position? named | |
| Default value None | |
| Parameter sets Something | |
| SYNTAX | |
| doer.exe something -Location <String> [-Awesome] [-Times <Int32>] | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *NotLastConsole_LBiCliArguments*>doer something -l here -t asd | |
| Unable to apply argument 'asd' to parameter Times | |
| -Times <Int32> | |
| number of times something was done | |
| Required? False | |
| Position? named | |
| Default value 1 | |
| Parameter sets Something | |
| SYNTAX | |
| doer.exe something -Location <String> [-Awesome] [-Times <Int32>] | |
| ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment