Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Todo.txt to Google Tasks #184

Merged
merged 4 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>();
}
}
rprouse marked this conversation as resolved.
Show resolved Hide resolved
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
Loading