Skip to content

Commit

Permalink
Merge pull request #184 from rprouse/todo_sync
Browse files Browse the repository at this point in the history
Sync Todo.txt to Google Tasks
  • Loading branch information
rprouse authored Sep 29, 2024
2 parents d381508 + 8095ae9 commit d1e8b3f
Show file tree
Hide file tree
Showing 19 changed files with 422 additions and 92 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration
name: Continuous Integration

on:
push:
Expand All @@ -13,6 +13,9 @@ jobs:
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v3
with:
submodules: true # Fetch and checkout submodules
fetch-depth: 0 # Ensure the full history is fetched, useful when dealing with submodules

- name: 💉 Install dependencies
run: dotnet restore
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
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
39 changes: 25 additions & 14 deletions Guppi.Application/DependencyInjection.cs
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>();
}
}
7 changes: 7 additions & 0 deletions Guppi.Application/Exceptions/ErrorException.cs
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)
{
}
7 changes: 3 additions & 4 deletions Guppi.Application/Exceptions/WarningException.cs
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)
{
}
}
18 changes: 18 additions & 0 deletions Guppi.Application/Extensions/ColoredStringExtensions.cs
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));
}
59 changes: 5 additions & 54 deletions Guppi.Application/Extensions/DateTimeExtensions.cs
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;
}
57 changes: 57 additions & 0 deletions Guppi.Application/Extensions/TimeIconExtensions.cs
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();
}
3 changes: 3 additions & 0 deletions Guppi.Application/Guppi.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Apis.Tasks.v1" Version="1.68.0.3468" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="OpenAI" Version="1.11.0" />
<PackageReference Include="Spectre.Console" Version="0.49.1" />
Expand All @@ -21,6 +22,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\dotnet-todo\src\todo.application\todo.application.csproj" />
<ProjectReference Include="..\dotnet-todo\src\todo.infrastructure\todo.infrastructure.csproj" />
<ProjectReference Include="..\Guppi.Domain\Guppi.Domain.csproj" />
</ItemGroup>

Expand Down
8 changes: 8 additions & 0 deletions Guppi.Application/Services/ITodoService.cs
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();
}
Loading

0 comments on commit d1e8b3f

Please sign in to comment.