You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -48,19 +48,19 @@ The things to note:
48
48
## Using Delegate Functions
49
49
The first approach allows for a simpler, slimmer solution and is best suited for smaller console apps that are just used to do just a few small tasks. Everything can be contained inside the `Main` method of `Program.cs`. Let's get right down to it:
1. The first thing to look it is where we add an "Add" command. This is done by calling `CLI.Command(string commandName, Func<Arguments, int> command, string helpText = null)`. `commandName` defines the name of the command, `command` defines the function body of the command, and the optional `helpText` is used for the usage printout as text to describe the command. This first example shows this method being called without any help text. This is the simplest possible implementation of a command in the CLI.
53
+
1. The first thing to look it is where we add an "Add" command. This is done by calling `CLIHandler.Command(string commandName, Func<Arguments, int> command, string helpText = null)`. `commandName` defines the name of the command, `command` defines the function body of the command, and the optional `helpText` is used for the usage printout as text to describe the command. This first example shows this method being called without any help text. This is the simplest possible implementation of a command in the CLI.
54
54
2. The second command is basically the same as the first, except that in this case, the help text is provided.
55
-
3. Lastly once we are done setting up the commands, we call `HandleMain` to have CLI handle the routing. The full signature of the `HandleMain` function is: `CLI.HandleMain(string[] args, char escapeCharacter = DefaultEscapeChar, bool ignoreCase = true)`. This example shows only the simples implementation: passing in the `string[] args`. The escape character and ignore case arguments are optional:
55
+
3. Lastly once we are done setting up the commands, we call `HandleMain` to have CLI handle the routing. The full signature of the `HandleMain` function is: `CLIHandler.HandleMain(string[] args, char escapeCharacter = DefaultEscapeChar, bool ignoreCase = true)`. This example shows only the simples implementation: passing in the `string[] args`. The escape character and ignore case arguments are optional:
56
56
1.**escapeCharacter**: The character that is used to signify a command name. The escape character comes before the command name. The default escape character is `/`.
57
57
2.**ignoreCase**: Ignore case indicates whether or not to use case insensitive searches on the command and argument names. By default, ignore case is enabled, meaning command and argument names are not case sensitive.
58
58
59
59
## Using Classes and Attributes
60
60
### A Simple Example
61
61
Classes and attributes are a more advanced method of using the CLI utility. It is best suited for a larger or more "public facing" console application and allows for more encapsulation and modularizaiton. This approach also provides more methods for including more detailed information in the usage printout, making this more useful as a "shared" interface. Let's start by taking a look at the simplest implementation of a class decorated with the attributes:
62
62
63
-

63
+

64
64
65
65
1. The first step is to implement the `ICLICommand` interface and decorate your class with the `Command` attribute. Without both, the CLI utility will ignore the class.
66
66
2. Next, you will need to define your arguments. These are properties decorated with the `Argument` attribute. The types of the attributes are restricted: either a `ICollection<string>` or primitive types, such as `string`, `int` or any other type directly convertable from a `string` are supported.
@@ -69,7 +69,7 @@ Classes and attributes are a more advanced method of using the CLI utility. It
69
69
### A Full Example
70
70
The attributes allow for more more fine-tuned control of the commands. Let's jump into an example:
71
71
72
-

72
+

73
73
74
74
1. The `Command` attribute has three optional settings:
75
75
1.**Description**: Provides a description for the command. This is used for the usage printout to describe the command. This walkthrough shows an example of the usage printout later.
0 commit comments