-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
331 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ArgsReading assembly | ||
|
||
## ArgsReading namespace | ||
|
||
| public type | description | | ||
| --- | --- | | ||
| class [ArgsReader](./ArgsReading/ArgsReader.md) | Helps process command-line arguments. | | ||
| class [ArgsReaderException](./ArgsReading/ArgsReaderException.md) | Thrown when an error occurs while processing command-line arguments. | | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# ArgsReader class | ||
|
||
Helps process command-line arguments. | ||
|
||
```csharp | ||
public sealed class ArgsReader | ||
``` | ||
|
||
## Public Members | ||
|
||
| name | description | | ||
| --- | --- | | ||
| [ArgsReader](ArgsReader/ArgsReader.md)(…) | Creates a reader for the specified command-line arguments. | | ||
| [LongOptionIgnoreCase](ArgsReader/LongOptionIgnoreCase.md) { get; set; } | True if long options (e.g. `--help`) should ignore case. (Default false.) | | ||
| [LongOptionIgnoreKebabCase](ArgsReader/LongOptionIgnoreKebabCase.md) { get; set; } | True if long options (e.g. `--dry-run`) should ignore "kebab case", i.e. allow `--dryrun`. (Default false.) | | ||
| [NoOptionsAfterDoubleDash](ArgsReader/NoOptionsAfterDoubleDash.md) { get; set; } | True if `--` is ignored and all following arguments are not read as options. (Default false.) | | ||
| [ShortOptionIgnoreCase](ArgsReader/ShortOptionIgnoreCase.md) { get; set; } | True if short options (e.g. `-h`) should ignore case. (Default false.) | | ||
| [ReadArgument](ArgsReader/ReadArgument.md)() | Reads the next non-option argument. | | ||
| [ReadArguments](ArgsReader/ReadArguments.md)() | Reads any remaining non-option arguments. | | ||
| [ReadFlag](ArgsReader/ReadFlag.md)(…) | Reads the specified flag, returning true if it is found. | | ||
| [ReadOption](ArgsReader/ReadOption.md)(…) | Reads the value of the specified option, if any. | | ||
| [VerifyComplete](ArgsReader/VerifyComplete.md)() | Confirms that all arguments were processed. | | ||
|
||
## Remarks | ||
|
||
To use this class, construct an `ArgsReader` with the command-line arguments from `Main`, read the supported options one at a time with [`ReadFlag`](./ArgsReader/ReadFlag.md) and [`ReadOption`](./ArgsReader/ReadOption.md), read any normal arguments with [`ReadArgument`](./ArgsReader/ReadArgument.md), and finally call [`VerifyComplete`](./ArgsReader/VerifyComplete.md), which throws an [`ArgsReaderException`](./ArgsReaderException.md) if any unsupported options or arguments haven't been read. | ||
|
||
## See Also | ||
|
||
* namespace [ArgsReading](../ArgsReading.md) | ||
* [ArgsReader.cs](https://github.com/ejball/ArgsReading/tree/master/src/ArgsReading/ArgsReader.cs) | ||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# ArgsReader constructor | ||
|
||
Creates a reader for the specified command-line arguments. | ||
|
||
```csharp | ||
public ArgsReader(IEnumerable<string> args) | ||
``` | ||
|
||
| parameter | description | | ||
| --- | --- | | ||
| args | The command-line arguments from `Main`. | | ||
|
||
## Exceptions | ||
|
||
| exception | condition | | ||
| --- | --- | | ||
| ArgumentNullException | `args` is `null`. | | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# ArgsReader.LongOptionIgnoreCase property | ||
|
||
True if long options (e.g. `--help`) should ignore case. (Default false.) | ||
|
||
```csharp | ||
public bool LongOptionIgnoreCase { get; set; } | ||
``` | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# ArgsReader.LongOptionIgnoreKebabCase property | ||
|
||
True if long options (e.g. `--dry-run`) should ignore "kebab case", i.e. allow `--dryrun`. (Default false.) | ||
|
||
```csharp | ||
public bool LongOptionIgnoreKebabCase { get; set; } | ||
``` | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# ArgsReader.NoOptionsAfterDoubleDash property | ||
|
||
True if `--` is ignored and all following arguments are not read as options. (Default false.) | ||
|
||
```csharp | ||
public bool NoOptionsAfterDoubleDash { get; set; } | ||
``` | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# ArgsReader.ReadArgument method | ||
|
||
Reads the next non-option argument. | ||
|
||
```csharp | ||
public string? ReadArgument() | ||
``` | ||
|
||
## Return Value | ||
|
||
The next non-option argument, or null if none remain. | ||
|
||
## Exceptions | ||
|
||
| exception | condition | | ||
| --- | --- | | ||
| [ArgsReaderException](../ArgsReaderException.md) | The next argument is an option. | | ||
|
||
## Remarks | ||
|
||
If the next argument is an option, this method throws an exception. If options can appear before normal arguments, be sure to read all options before reading any normal arguments. | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# ArgsReader.ReadArguments method | ||
|
||
Reads any remaining non-option arguments. | ||
|
||
```csharp | ||
public IReadOnlyList<string> ReadArguments() | ||
``` | ||
|
||
## Return Value | ||
|
||
The remaining non-option arguments, if any. | ||
|
||
## Exceptions | ||
|
||
| exception | condition | | ||
| --- | --- | | ||
| [ArgsReaderException](../ArgsReaderException.md) | A remaining argument is an option. | | ||
|
||
## Remarks | ||
|
||
If any remaining arguments are options, this method throws an exception. If options can appear before normal arguments, be sure to read all options before reading any normal arguments. | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# ArgsReader.ReadFlag method | ||
|
||
Reads the specified flag, returning true if it is found. | ||
|
||
```csharp | ||
public bool ReadFlag(string name) | ||
``` | ||
|
||
| parameter | description | | ||
| --- | --- | | ||
| name | The name of the specified flag. | | ||
|
||
## Return Value | ||
|
||
True if the specified flag was found on the command line. | ||
|
||
## Exceptions | ||
|
||
| exception | condition | | ||
| --- | --- | | ||
| ArgumentNullException | `name` is `null`. | | ||
| ArgumentException | One of the names is empty. | | ||
|
||
## Remarks | ||
|
||
If the flag is found, the method returns `true` and the flag is removed. If `ReadFlag` is called again with the same name, it will return `false`, unless the same flag appears twice on the command line. | ||
|
||
To support multiple names for the same flag, use a `|` to separate them, e.g. use `help|h|?` to support three different names for a help flag. | ||
|
||
Single-character names use a single hyphen, e.g. `-h`. Longer names use a double hyphen, e.g. `--help`. | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# ArgsReader.ReadOption method | ||
|
||
Reads the value of the specified option, if any. | ||
|
||
```csharp | ||
public string? ReadOption(string name) | ||
``` | ||
|
||
| parameter | description | | ||
| --- | --- | | ||
| name | The name of the specified option. | | ||
|
||
## Return Value | ||
|
||
The specified option if it was found on the command line; `null` otherwise. | ||
|
||
## Exceptions | ||
|
||
| exception | condition | | ||
| --- | --- | | ||
| ArgumentNullException | `name` is `null`. | | ||
| ArgumentException | One of the names is empty. | | ||
| [ArgsReaderException](../ArgsReaderException.md) | The argument that must follow the option is missing. | | ||
|
||
## Remarks | ||
|
||
If the option is found, the method returns the command-line argument after the option and both arguments are removed. If `ReadOption` is called again with the same name, it will return `null`, unless the same option appears twice on the command line. | ||
|
||
To support multiple names for the same option, use a vertical bar (`|`) to separate them, e.g. use `n|name` to support two different names for a module option. | ||
|
||
Single-character names use a single hyphen, e.g. `-n example`. Longer names use a double hyphen, e.g. `--name example`. | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# ArgsReader.ShortOptionIgnoreCase property | ||
|
||
True if short options (e.g. `-h`) should ignore case. (Default false.) | ||
|
||
```csharp | ||
public bool ShortOptionIgnoreCase { get; set; } | ||
``` | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# ArgsReader.VerifyComplete method | ||
|
||
Confirms that all arguments were processed. | ||
|
||
```csharp | ||
public void VerifyComplete() | ||
``` | ||
|
||
## Exceptions | ||
|
||
| exception | condition | | ||
| --- | --- | | ||
| [ArgsReaderException](../ArgsReaderException.md) | A command-line argument was not read. | | ||
|
||
## See Also | ||
|
||
* class [ArgsReader](../ArgsReader.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# ArgsReaderException class | ||
|
||
Thrown when an error occurs while processing command-line arguments. | ||
|
||
```csharp | ||
public sealed class ArgsReaderException : Exception | ||
``` | ||
|
||
## Public Members | ||
|
||
| name | description | | ||
| --- | --- | | ||
| [ArgsReaderException](ArgsReaderException/ArgsReaderException.md)(…) | Creates an exception. | | ||
|
||
## See Also | ||
|
||
* namespace [ArgsReading](../ArgsReading.md) | ||
* [ArgsReaderException.cs](https://github.com/ejball/ArgsReading/tree/master/src/ArgsReading/ArgsReaderException.cs) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ArgsReaderException constructor | ||
|
||
Creates an exception. | ||
|
||
```csharp | ||
public ArgsReaderException(string message, Exception? innerException = null) | ||
``` | ||
|
||
| parameter | description | | ||
| --- | --- | | ||
| message | The exception message. | | ||
| innerException | The inner exception. | | ||
|
||
## See Also | ||
|
||
* class [ArgsReaderException](../ArgsReaderException.md) | ||
* namespace [ArgsReading](../../ArgsReading.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ArgsReading.dll --> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
### https://ejball.com/RepoName/ | ||
### https://ejball.com/ArgsReading/ |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# ProjectName | ||
# ArgsReading | ||
|
||
[![NuGet](https://img.shields.io/nuget/v/ProjectName.svg)](https://www.nuget.org/packages/ProjectName) | ||
**ArgsReading** is a .NET library for reading command-line arguments. | ||
|
||
[![NuGet](https://img.shields.io/nuget/v/ArgsReading.svg)](https://www.nuget.org/packages/ArgsReading) | ||
|
||
## Usage | ||
|
||
See the [reference documentation](ProjectName.md). | ||
**ArgsReading** is considerably simpler (and less powerful) than most command-line argument libraries. | ||
|
||
It does not support registering a list of options, data type conversion, binding options to the properties of a class, documenting options, or displaying usage. If you want those features, use a competing library such as [CommandLineParser](https://www.nuget.org/packages/CommandLineParser) or [McMaster.Extensions.CommandLineUtils](https://www.nuget.org/packages/McMaster.Extensions.CommandLineUtils/). | ||
|
||
To use this library, construct an [ArgsReader](ArgsReading/ArgsReader/ArgsReader.md) with the command-line arguments, read the supported options one at a time with [ReadFlag](ArgsReading/ArgsReader/ReadFlag.md) and [ReadOption](ArgsReading/ArgsReader/ReadOption.md), read any normal arguments with [ReadArgument](ArgsReading/ArgsReader/ReadArgument.md), and finally call [VerifyComplete](ArgsReading/ArgsReader/VerifyComplete.md), which throws an [ArgsReaderException](ArgsReading/ArgsReaderException.md) if any unsupported options or arguments haven't been read. | ||
|
||
For more information, consult the [reference documentation](ArgsReading.md). |