Last active
February 24, 2017 09:34
-
-
Save dgg/f365528edb6afb7cf1a494f65b49c50f to your computer and use it in GitHub Desktop.
not-last-console-PowerArgs
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
| [ArgExceptionBehavior(ArgExceptionPolicy.StandardExceptionHandling)] | |
| public class Doer | |
| { | |
| [ArgRequired] | |
| [ArgPosition(0)] | |
| public string Action { get; set; } | |
| [HelpHook, ArgShortcut("-?"), ArgDescription("Shows this help")] | |
| public bool Help { get; set; } | |
| public Something SomethingArgs { get; set; } | |
| public SomethingElse SomethingElseArgs { get; set; } | |
| public static void Something(Something args) | |
| { | |
| var options = new OptionsForSomething | |
| { | |
| Location = args.Location, | |
| Times = args.Times, | |
| Awesome = args.Awesome | |
| }; | |
| var command = new ADoerOfSomething(System.Console.Out); | |
| command.Do(options); | |
| } | |
| public static void SomethingElse(SomethingElse args) | |
| { | |
| var options = new OptionsForSomethingElse | |
| { | |
| Locations = args.Locations, | |
| NotSoAwesome = !args.Awesome | |
| }; | |
| var command = new ADoerOfSomethingElse(System.Console.Out); | |
| command.Do(options); | |
| } | |
| } | |
| public class Something | |
| { | |
| [ArgRequired, ArgShortcut("l"), ArgDescription("place where the something was done")] | |
| public string Location { get; set; } | |
| [ArgShortcut("t"), ArgDescription("number of times something was done"), ArgDefaultValue(1)] | |
| public int Times { get; set; } | |
| [ArgShortcut("a"), ArgDescription("include if the something was awesome")] | |
| public bool Awesome { get; set; } | |
| } | |
| public class SomethingElse | |
| { | |
| [ArgShortcut("l"), ArgRequired, ArgDescription("places where the something else was done")] | |
| public string[] Locations { get; set; } | |
| [ArgShortcut("a"), ArgDescription("include if the something else was awesome")] | |
| public bool Awesome { get; set; } | |
| } |
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) | |
| { | |
| ArgAction<Doer> action = Args.InvokeAction<Doer>(args); | |
| } | |
| } |
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_PowerArgs*>doer something | |
| The argument 'Location' is required | |
| GlobalOption Description | |
| Help (-?) Shows this help | |
| Something - | |
| Usage - doer Something -options | |
| Something Options | |
| Option Description | |
| Location* (-l) place where the something was done | |
| Times (-t) number of times something was done [Default='1'] | |
| Awesome (-a) include if the something was awesome |
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_PowerArgs*>doer somethingelse -l here,there | |
| I did something else not so awesome in here, there |
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_PowerArgs*>doer something -Location here -t asd | |
| value must be an integer: asd | |
| GlobalOption Description | |
| Help (-?) Shows this help | |
| Something - | |
| Usage - doer Something -options | |
| Something Options | |
| Option Description | |
| Location* (-l) place where the something was done | |
| Times (-t) number of times something was done [Default='1'] | |
| Awesome (-a) include if the something was awesome |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment