-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from rprouse/todo_sync
Sync Todo.txt to Google Tasks
- Loading branch information
Showing
19 changed files
with
422 additions
and
92 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
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,3 @@ | ||
[submodule "dotnet-todo"] | ||
path = dotnet-todo | ||
url = [email protected]:rprouse/dotnet-todo.git |
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,22 +1,33 @@ | ||
using System.Linq; | ||
using System.IO; | ||
using System; | ||
using Guppi.Application.Services; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Guppi.Application; | ||
|
||
public static class DependencyInjection | ||
{ | ||
public static IServiceCollection AddApplication(this IServiceCollection services) => services | ||
.AddTransient<IAdventOfCodeService, AdventOfCodeService>() | ||
.AddTransient<IAsciiService, AsciiService>() | ||
.AddTransient<ICalendarService, CalendarService>() | ||
.AddTransient<IDictionaryService, DictionaryService>() | ||
.AddTransient<IGitService, GitService>() | ||
.AddTransient<IHueLightService, HueLightService>() | ||
.AddTransient<INoteService, NoteService>() | ||
.AddTransient<IOpenAIService, OpenAIService>() | ||
.AddTransient<ISerialPortService, SerialPortService>() | ||
.AddTransient<IStravaService, StravaService>() | ||
.AddTransient<IUtilitiesService, UtilitiesService>() | ||
.AddTransient<IWeatherService, WeatherService>(); | ||
public static IServiceCollection AddApplication(this IServiceCollection services) | ||
{ | ||
// Setup the Todo application's services | ||
string configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".todo.json"); | ||
|
||
Alteridem.Todo.Application.DependencyInjection.AddApplication(services); | ||
Alteridem.Todo.Infrastructure.DependencyInjection.AddInfrastructure(services, configFile); | ||
|
||
return services | ||
.AddTransient<IAdventOfCodeService, AdventOfCodeService>() | ||
.AddTransient<IAsciiService, AsciiService>() | ||
.AddTransient<ICalendarService, CalendarService>() | ||
.AddTransient<IDictionaryService, DictionaryService>() | ||
.AddTransient<IGitService, GitService>() | ||
.AddTransient<IHueLightService, HueLightService>() | ||
.AddTransient<INoteService, NoteService>() | ||
.AddTransient<IOpenAIService, OpenAIService>() | ||
.AddTransient<ISerialPortService, SerialPortService>() | ||
.AddTransient<IStravaService, StravaService>() | ||
.AddSingleton<ITodoService, TodoService>() | ||
.AddTransient<IUtilitiesService, UtilitiesService>() | ||
.AddTransient<IWeatherService, WeatherService>(); | ||
} | ||
} |
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,7 @@ | ||
using System; | ||
|
||
namespace Guppi.Application.Exceptions; | ||
|
||
public class ErrorException(string message) : Exception(message) | ||
{ | ||
} |
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,8 +1,7 @@ | ||
using System; | ||
|
||
namespace Guppi.Application.Exceptions | ||
namespace Guppi.Application.Exceptions; | ||
|
||
public class WarningException(string message) : Exception(message) | ||
{ | ||
public class WarningException(string message) : Exception(message) | ||
{ | ||
} | ||
} |
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,18 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Alteridem.Todo.Domain.Common; | ||
using ColoredConsole; | ||
|
||
namespace Guppi.Application.Extensions; | ||
|
||
public static class ColoredStringExtensions | ||
{ | ||
public static ColorToken ToColorToken(this ColoredString coloredString) => | ||
new ColorToken(coloredString.Text, coloredString.Color, coloredString.BackgroundColor); | ||
|
||
public static ColorToken[] ToColorTokens(this IEnumerable<ColoredString> coloredStrings) => | ||
coloredStrings.Select(cs => cs.ToColorToken()).ToArray(); | ||
|
||
public static string ToPlainString(this IEnumerable<ColoredString> coloredStrings) => | ||
string.Join(null, coloredStrings.Select(c => c.Text)); | ||
} |
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,58 +1,9 @@ | ||
using System; | ||
using Spectre.Console; | ||
|
||
namespace Guppi.Application.Extensions | ||
{ | ||
public static class TimeIconExtensions | ||
{ | ||
private static string[] Clocks = new[] | ||
{ | ||
Emoji.Known.TwelveOClock, | ||
Emoji.Known.OneOClock, | ||
Emoji.Known.TwoOClock, | ||
Emoji.Known.ThreeOClock, | ||
Emoji.Known.FourOClock, | ||
Emoji.Known.FiveOClock, | ||
Emoji.Known.SixOClock, | ||
Emoji.Known.SevenOClock, | ||
Emoji.Known.EightOClock, | ||
Emoji.Known.NineOClock, | ||
Emoji.Known.TenOClock, | ||
Emoji.Known.ElevenOClock, | ||
}; | ||
|
||
private static string[] HalfClocks = new[] | ||
{ | ||
Emoji.Known.TwelveThirty, | ||
Emoji.Known.OneThirty, | ||
Emoji.Known.TwoThirty, | ||
Emoji.Known.ThreeThirty, | ||
Emoji.Known.FourThirty, | ||
Emoji.Known.FiveThirty, | ||
Emoji.Known.SixThirty, | ||
Emoji.Known.SevenThirty, | ||
Emoji.Known.EightThirty, | ||
Emoji.Known.NineThirty, | ||
Emoji.Known.TenThirty, | ||
Emoji.Known.ElevenThirty, | ||
}; | ||
namespace Guppi.Application.Extensions; | ||
|
||
/// <summary> | ||
/// Gets the clock emoji that matches the given time | ||
/// </summary> | ||
/// <param name="time"></param> | ||
/// <returns></returns> | ||
public static string GetEmoji(this DateTime time) | ||
{ | ||
int hour = time.Hour % 12; | ||
return time.Minute < 30 ? Clocks[hour] : HalfClocks[hour]; | ||
} | ||
|
||
/// Gets the clock emoji that matches the given time | ||
/// </summary> | ||
/// <param name="time"></param> | ||
/// <returns></returns> | ||
public static string GetEmoji(this DateTime? time) => | ||
time is null ? Emoji.Known.TwelveOClock : time.Value.GetEmoji(); | ||
} | ||
public static class DateTimeExtensions | ||
{ | ||
public static DateTimeOffset GetRfc3339Date(this string date) => | ||
DateTimeOffset.TryParse(date, out DateTimeOffset result) ? result : DateTimeOffset.Now; | ||
} |
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,57 @@ | ||
using System; | ||
using Spectre.Console; | ||
|
||
namespace Guppi.Application.Extensions; | ||
|
||
public static class TimeIconExtensions | ||
{ | ||
private static readonly string[] Clocks = | ||
[ | ||
Emoji.Known.TwelveOClock, | ||
Emoji.Known.OneOClock, | ||
Emoji.Known.TwoOClock, | ||
Emoji.Known.ThreeOClock, | ||
Emoji.Known.FourOClock, | ||
Emoji.Known.FiveOClock, | ||
Emoji.Known.SixOClock, | ||
Emoji.Known.SevenOClock, | ||
Emoji.Known.EightOClock, | ||
Emoji.Known.NineOClock, | ||
Emoji.Known.TenOClock, | ||
Emoji.Known.ElevenOClock, | ||
]; | ||
|
||
private static readonly string[] HalfClocks = | ||
[ | ||
Emoji.Known.TwelveThirty, | ||
Emoji.Known.OneThirty, | ||
Emoji.Known.TwoThirty, | ||
Emoji.Known.ThreeThirty, | ||
Emoji.Known.FourThirty, | ||
Emoji.Known.FiveThirty, | ||
Emoji.Known.SixThirty, | ||
Emoji.Known.SevenThirty, | ||
Emoji.Known.EightThirty, | ||
Emoji.Known.NineThirty, | ||
Emoji.Known.TenThirty, | ||
Emoji.Known.ElevenThirty, | ||
]; | ||
|
||
/// <summary> | ||
/// Gets the clock emoji that matches the given time | ||
/// </summary> | ||
/// <param name="time"></param> | ||
/// <returns></returns> | ||
public static string GetEmoji(this DateTime time) | ||
{ | ||
int hour = time.Hour % 12; | ||
return time.Minute < 30 ? Clocks[hour] : HalfClocks[hour]; | ||
} | ||
|
||
/// Gets the clock emoji that matches the given time | ||
/// </summary> | ||
/// <param name="time"></param> | ||
/// <returns></returns> | ||
public static string GetEmoji(this DateTime? time) => | ||
time is null ? Emoji.Known.TwelveOClock : time.Value.GetEmoji(); | ||
} |
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,8 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Guppi.Application.Services; | ||
|
||
public interface ITodoService | ||
{ | ||
Task Sync(); | ||
} |
Oops, something went wrong.