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
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,10 @@
20
20
</p>
21
21
22
22
**CliFx** is an opinionated framework for building command-line applications.
23
-
It provides a model to express command interactions through a relationship of classes and properties, skipping all the low-level infrastructural concerns like argument parsing, routing, error handling, and help generation.
23
+
It provides a model for expressing command interactions through classes and properties, skipping all the low-level infrastructure concerns like argument parsing, routing, error handling, and help generation.
24
24
25
-
**This is the readme for CliFx v3 (alpha). For v2, see [this readme](https://github.com/Tyrrrz/CliFx/blob/2.3.6/Readme.md)**.
25
+
> [!NOTE]
26
+
> This is the readme for CliFx v3 (alpha). For v2, see [this readme](https://github.com/Tyrrrz/CliFx/blob/2.3.6/Readme.md).
26
27
27
28
## Terms of use<sup>[[?]](https://github.com/Tyrrrz/.github/blob/prime/docs/why-so-political.md)</sup>
28
29
@@ -42,7 +43,7 @@ To learn more about the war and how you can help, [click here](https://tyrrrz.me
42
43
## Features
43
44
44
45
- Complete application framework, not just an argument parser
45
-
-Minimum boilerplate and easy to get started
46
+
-Minimal boilerplate and easy to get started
46
47
- Class-first configuration via attributes
47
48
- Comprehensive auto-generated help text
48
49
- Support for deeply nested command hierarchies
@@ -97,12 +98,12 @@ public partial class LogCommand : ICommand
97
98
98
99
> [!IMPORTANT]
99
100
> The command type must be declared as `partial` so that **CliFx** can extend it with necessary metadata and behavior.
100
-
> If the type is nested within other types, all of them must be also marked as `partial`.
101
+
> If the type is nested within other types, all of them must also be marked as `partial`.
101
102
102
103
In order to satisfy `ICommand`'s contract, the type needs to define an `ExecuteAsync(...)` method which contains the command's execution logic.
103
104
As the only parameter, this method takes an instance of `IConsole` — a decoupled abstraction used in place of `System.Console` to write text, read binary data, or otherwise interact with the console.
104
105
105
-
Beyond that, your command will probably also need to be able to receive some input from the user.
106
+
Beyond that, your command will probably also need to receive some input from the user.
106
107
This is achieved by defining properties and attaching the `[CommandParameter]` and `[CommandOption]` attributes to bind them as either parameters or options.
107
108
108
109
The command in the above example serves as a simple logarithm calculator that has two inputs: a positional parameter for the logarithm value (bound to `Value`) and a named option for the logarithm base (bound to `Base`).
@@ -230,7 +231,7 @@ This allows the user to run the application in one of the two following ways:
230
231
```console
231
232
$ ./myapp log 100 -b 10
232
233
233
-
4
234
+
2
234
235
235
236
$ ./myapp sum 1 2 3
236
237
@@ -483,7 +484,7 @@ By default, the framework will try to automatically infer a suitable converter f
483
484
- Converted by calling `.ctor(...)` with the array of converted values
484
485
- Covers collection types like `List<T>`, `HashSet<T>`, etc.
485
486
486
-
For example, here is an example command that showcases some of these built-in conversions:
487
+
For example, here is a command that showcases some of these built-in conversions:
487
488
488
489
```csharp
489
490
[Command("search", Description="Searches for files matching a pattern.")]
@@ -686,7 +687,7 @@ The parser's context-free nature has several implications on how it consumes arg
686
687
For example, `./myapp -i file1.txt file2.txt` will always be parsed as an option with multiple values, regardless of the arity of the underlying property it's bound to.
687
688
Similarly, unseparated arguments in the form of `./myapp -ofile` will be treated as five distinct options `'o'`, `'f'`, `'i'`, `'l'`, `'e'`, instead of `'o'` being set to value `"file"`.
688
689
689
-
These rules also make the order of arguments important — command-line string is expected to follow this pattern:
690
+
These rules also make the order of arguments important — the command-line string is expected to follow this pattern:
690
691
691
692
```console
692
693
$ ./myapp [command] [...parameters] [...options]
@@ -698,7 +699,7 @@ Because **CliFx** takes responsibility for the application's entire lifecycle, i
698
699
To facilitate that, it uses an interface called `ITypeInstantiator` that determines how to create a new instance of a given type.
699
700
700
701
The default implementation of `ITypeInstantiator` only supports types that have public parameter-less constructors, which is sufficient for most common scenarios.
701
-
However, in some cases you may want to define a custom initializer, for example when integrating with an external dependency container.
702
+
However, in some cases you may want to define a custom instantiator, for example when integrating with an external dependency container.
702
703
703
704
To do that, pass a custom `ITypeInstantiator` or a factory delegate to the `UseTypeInstantiator(...)` method when building the application:
704
705
@@ -819,7 +820,7 @@ You can run `myapp [command] --help` to show help for a specific command.
819
820
To see the list of commands nested under a specific command, the user can refine their help request by specifying the corresponding command name before the help option:
0 commit comments