mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Add required modifiers
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user