-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
9f4cc4a
commit c33562f
Showing
6 changed files
with
62 additions
and
1 deletion.
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,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
using System.Text; | ||
using Todo.CLI.Handlers; | ||
|
||
namespace Todo.CLI.Commands | ||
{ | ||
public class AddCommand : Command | ||
{ | ||
public AddCommand(IServiceProvider serviceProvider) : base("add") | ||
{ | ||
Description = "Adds a to do item."; | ||
|
||
AddArgument(GetSubjectArgument()); | ||
|
||
Handler = AddCommandHandler.Create(serviceProvider); | ||
} | ||
|
||
private Argument GetSubjectArgument() | ||
{ | ||
return new Argument("subject") | ||
{ | ||
Description = "The subject of the new to do item.", | ||
ArgumentType = typeof(string) | ||
}; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
using System.IO; | ||
using System.Reflection; | ||
using Todo.Core; | ||
|
||
namespace Todo.CLI.Handlers | ||
{ | ||
public class AddCommandHandler | ||
{ | ||
public static ICommandHandler Create(IServiceProvider serviceProvider) | ||
{ | ||
return CommandHandler.Create<string>(async (subject) => | ||
{ | ||
var todoItemRepository = (ITodoItemRepository)serviceProvider.GetService(typeof(ITodoItemRepository)); | ||
await todoItemRepository.AddAsync(subject); | ||
}); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"ClientId": "5c594999-30b1-4a68-afcf-56ce11715b4d", | ||
"Scopes": [ | ||
"user.read", | ||
"tasks.read" | ||
"tasks.readwrite" | ||
] | ||
} | ||
} |
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