Skip to content

Commit

Permalink
update docs for next release
Browse files Browse the repository at this point in the history
  • Loading branch information
drewburlingame committed Jan 8, 2025
1 parent 2565c1d commit af8c7eb
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 13 deletions.
22 changes: 13 additions & 9 deletions docs/Diagnostics/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CommandDotNet throws two types of exceptions

## Two patterns for handling exceptions

### UseErrorHandler deletage
### UseErrorHandler delegate

<!-- snippet: exceptions_use_error_handler_delegate -->
<a id='snippet-exceptions_use_error_handler_delegate'></a>
Expand All @@ -25,7 +25,7 @@ static int Main(string[] args)
.UseErrorHandler((ctx, ex) =>
{
(ctx?.Console.Error ?? Console.Error).WriteLine(ex.Message);
return ExitCodes.Error.Result;
return ExitCodes.ErrorAsync.Result;
})
.Run(args);
}
Expand Down Expand Up @@ -62,7 +62,7 @@ static int Main(string[] args)
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
return ExitCodes.Error.Result;
return ExitCodes.ErrorAsync.Result;
}
}
```
Expand All @@ -78,12 +78,16 @@ CommandDotnet has the following pre-defined exit codes
```cs
public static class ExitCodes
{
public static Task<int> Success => Task.FromResult(0);
public static Task<int> Error => Task.FromResult(1);
public static Task<int> ValidationError => Task.FromResult(2);
public static int Success => 0;
public static int Error => 1;
public static int ValidationError => 2;

public static Task<int> SuccessAsync => Task.FromResult(Success);
public static Task<int> ErrorAsync => Task.FromResult(Error);
public static Task<int> ValidationErrorAsync => Task.FromResult(ValidationError);
}
```
<sup><a href='https://github.com/bilal-fazlani/commanddotnet/blob/master/CommandDotNet/ExitCodes.cs#L5-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-exitcodes_class' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/bilal-fazlani/commanddotnet/blob/master/CommandDotNet/ExitCodes.cs#L5-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-exitcodes_class' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

CommandDotNet internal errors are generally captured and return `ExitCodes.Error` (1).
Expand Down Expand Up @@ -129,7 +133,7 @@ Use this for user related errors where it could be helpful for them to see the h

### Printing config information

Configuration can be printed with `appRunner.ToString()`. See the [Command Logger > AppConfig](command-logger.md#appconfig) section for an example.
Configuration can be printed with `appRunner.ToString()`. See the [Command Logger > AppConfig](command-logger.md#include-appconfig) section for an example.

Alternatively, `CommandLogger.Log(ctx)` can be used to output CommandLogger for exception handling.

Expand Down Expand Up @@ -171,7 +175,7 @@ private static int ErrorHandler(CommandContext? ctx, Exception exception)
// if the exception occurred before a command could be parsed
ctx?.PrintHelp();

return ExitCodes.Error.Result;
return ExitCodes.ErrorAsync.Result;
}

public void Throw(string message)
Expand Down
5 changes: 5 additions & 0 deletions docs/ReleaseNotes/CommandDotNet.IoC.Autofac.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CommandDotNet.IoC.AutoFac

## 7.0.0

* add support for net9
* drop support for net6 and net7

## 6.0.0

* upgrade to Autofac 8.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CommandDotNet.IoC.MicrosoftDependencyInjection

## 7.0.0

* add support for net9
* drop support for net6 and net7

## 6.0.0

* upgrade to Microsoft.Extensions.DependencyInjection 8.0.0
Expand Down
5 changes: 5 additions & 0 deletions docs/ReleaseNotes/CommandDotNet.IoC.SimpleInjector.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CommandDotNet.IoC.SimpleInjector

## 6.0.0

* add support for net9
* drop support for net6 and net7

## 5.0.2

* support dotnet 7
Expand Down
5 changes: 5 additions & 0 deletions docs/ReleaseNotes/CommandDotNet.NameCasing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CommandDotNet.NameCasing

## 5.0.0

* add support for net9
* drop support for net6 and net7

## 4.0.2

* support dotnet 7
Expand Down
5 changes: 5 additions & 0 deletions docs/ReleaseNotes/CommandDotNet.NewerReleasesAlerts.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CommandDotNet.NewerReleasesAlerts

## 5.0.0

* add support for net9
* drop support for net6 and net7

## 4.0.2

* support dotnet 7
Expand Down
5 changes: 5 additions & 0 deletions docs/ReleaseNotes/CommandDotNet.Spectre.Testing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CommandDotNet.Spectre.Testing

## 4.0.0

* add support for net9
* drop support for net6 and net7

## 3.0.2

* support dotnet 7
Expand Down
5 changes: 5 additions & 0 deletions docs/ReleaseNotes/CommandDotNet.Spectre.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CommandDotNet.Spectre

## 4.0.0

* add support for net9
* drop support for net6 and net7

## 3.0.2

* support dotnet 7
Expand Down
5 changes: 5 additions & 0 deletions docs/ReleaseNotes/CommandDotNet.TestTools.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CommandDotNet.TestTools

## 7.0.0

* add support for net9
* drop support for net6 and net7

## 6.0.4

* [#501](https://github.com/bilal-fazlani/commanddotnet/issues/501) replace LogProvider `GetCurrentClassLogger` usage with `GetLogger` to better support AOT apps.
Expand Down
12 changes: 9 additions & 3 deletions docs/ReleaseNotes/CommandDotNet.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

* add support for net9
* drop support for net6 and net7
* rename [ExitCodes properties](../Diagnostics/exceptions.md#exit-codes). Previous properties that returned `Task<int>` now return `int` and new properties added postfixed with `Async` to return `Task<int>`.
* support nullable objects in IInvocation, dependency resolvers and parameter resolvers.
* IInvocation.ParameterValues changed from `object[]` to `object?[]`
* Generic constraint changed from `class` to `class?` for
* IDependencyResolver { Resolve<T>(), ResolveOrDefault<T>() } extension methods
* AppConfigBuilder.UseParameterResolver, allowing a nullable type to be registered

## 7.0.5

Expand Down Expand Up @@ -338,7 +344,7 @@ Now it will suggest the correct syntax to the user.

Expose DefaultSources.GetValueFunc for host apps to reuse logic for alternate configuration sources.

See the new [.Net Core Config](../ArgumentValues/default-values-from-config.md#.net-core-config) section for an example.
See the new [.Net Core Config](../ArgumentValues/default-values-from-config.md#net-core-config) section for an example.

## 4.1.7

Expand Down Expand Up @@ -710,8 +716,8 @@ Option & Operand & Command should now be created without a parent command. Paren

### Feature

#### [%UsageAppName%](../Help/help.md#usageappname-tempate)
To show usage examples in a command description, extended help or overridden usage section, use %UsageAppName%. This text will be replaced usage app name from one of the options above. See [the help docs](../Help/help.md#usageappname-tempate) for more.
#### [%UsageAppName%](../Help/help.md#template-variables)
To show usage examples in a command description, extended help or overridden usage section, use %AppName%. This text will be replaced usage app name from one of the options above. See [the help docs](../Help/help.md#template-variables) for more.

### API

Expand Down
2 changes: 1 addition & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ hide:
- Auto prompt for missing arguments (optional)
- Spectre AnsiConsole integration for alternate prompting experience

- [x] Default from EnvVar ([docs](ArgumentValues/default-values-from-config.md##environment-variables))
- [x] Default from EnvVar ([docs](ArgumentValues/default-values-from-config.md#environment-variables))
> values show as defaults in command help
- [x] Default from AppSetting ([docs](ArgumentValues/default-values-from-config.md#appsettings))
Expand Down

0 comments on commit af8c7eb

Please sign in to comment.