Add required modifiers

This commit is contained in:
Oleksii Holub
2022-12-08 03:08:58 +02:00
parent aac9c968eb
commit 15150cb3ed
4 changed files with 8 additions and 8 deletions

View File

@@ -14,10 +14,10 @@ public partial class BookAddCommand : ICommand
private readonly LibraryProvider _libraryProvider;
[CommandParameter(0, Name = "title", Description = "Book title.")]
public string Title { get; init; } = "";
public required string Title { get; init; }
[CommandOption("author", 'a', IsRequired = true, Description = "Book author.")]
public string Author { get; init; } = "";
public required string Author { get; init; }
[CommandOption("published", 'p', Description = "Book publish date.")]
public DateTimeOffset Published { get; init; } = CreateRandomDate();

View File

@@ -13,7 +13,7 @@ public class BookCommand : ICommand
private readonly LibraryProvider _libraryProvider;
[CommandParameter(0, Name = "title", Description = "Title of the book to retrieve.")]
public string Title { get; init; } = "";
public required string Title { get; init; }
public BookCommand(LibraryProvider libraryProvider)
{

View File

@@ -12,7 +12,7 @@ public class BookRemoveCommand : ICommand
private readonly LibraryProvider _libraryProvider;
[CommandParameter(0, Name = "title", Description = "Title of the book to remove.")]
public string Title { get; init; } = "";
public required string Title { get; init; }
public BookRemoveCommand(LibraryProvider libraryProvider)
{

View File

@@ -383,7 +383,7 @@ If the user does not provide value for such option through command line argument
public class AuthCommand : ICommand
{
[CommandOption("token", IsRequired = true, EnvironmentVariable = "AUTH_TOKEN")]
public string AuthToken { get; init; }
public required string AuthToken { get; init; }
public ValueTask ExecuteAsync(IConsole console)
{
@@ -500,10 +500,10 @@ This special exception can be used to print an error message to the console, ret
public class DivideCommand : ICommand
{
[CommandOption("dividend", IsRequired = true)]
public double Dividend { get; init; }
public required double Dividend { get; init; }
[CommandOption("divisor", IsRequired = true)]
public double Divisor { get; init; }
public required double Divisor { get; init; }
public ValueTask ExecuteAsync(IConsole console)
{