diff --git a/Guppi.Console/Guppi.Console.csproj b/Guppi.Console/Guppi.Console.csproj
index 75b2944..0d07e7e 100644
--- a/Guppi.Console/Guppi.Console.csproj
+++ b/Guppi.Console/Guppi.Console.csproj
@@ -13,7 +13,7 @@
https://github.com/rprouse/guppi
https://github.com/rprouse/guppi
dotnet-guppi
- 7.0.1
+ 7.1.0
true
guppi
./nupkg
diff --git a/Guppi.Console/Properties/launchSettings.json b/Guppi.Console/Properties/launchSettings.json
index 5dfa7a2..c4a8805 100644
--- a/Guppi.Console/Properties/launchSettings.json
+++ b/Guppi.Console/Properties/launchSettings.json
@@ -4,6 +4,10 @@
"commandName": "Project",
"commandLineArgs": "calendar agenda"
},
+ "Guppi calendar month": {
+ "commandName": "Project",
+ "commandLineArgs": "calendar month -m --offset 3"
+ },
"Guppi todo sync": {
"commandName": "Project",
"commandLineArgs": "todo sync"
diff --git a/Guppi.Console/Skills/CalendarSkill.cs b/Guppi.Console/Skills/CalendarSkill.cs
index ed25906..0038dd4 100644
--- a/Guppi.Console/Skills/CalendarSkill.cs
+++ b/Guppi.Console/Skills/CalendarSkill.cs
@@ -50,12 +50,17 @@ public IEnumerable GetCommands()
}, markdown, table);
var nextMonth = new Option(["--next", "-n"], "Display next month's calendar");
- var month = new Command("month", "Displays this month's calendar") { markdown, nextMonth };
- month.SetHandler(async (bool markdown, bool nextMonth) =>
+ var offset = new Option(["--offset", "-o"], "Offset the month by a number of months, e.g. -1 for last month, 0 for this month, 1 for next month");
+ nextMonth.SetDefaultValue(false);
+ offset.SetDefaultValue(0);
+ var month = new Command("month", "Displays this month's calendar") { markdown, nextMonth, offset };
+ month.SetHandler(async (bool markdown, bool nextMonth, int offset) =>
{
- if (markdown) await MonthMarkdown(nextMonth);
- else Month(nextMonth);
- }, markdown, nextMonth);
+ int monthOffset = nextMonth ? 1 : offset;
+ (DateOnly start, DateOnly end) = GetMonthRange(monthOffset);
+ if (markdown) await MonthMarkdown(start, end);
+ else Month(start, end);
+ }, markdown, nextMonth, offset);
var free = new Command("free", "Displays free time for a given day");
free.AddArgument(new Argument("date", "The date to check"));
@@ -276,10 +281,8 @@ private static string JoinLink(Core.Entities.Calendar.Event eventItem) =>
private static string TableLinkedSummary(Core.Entities.Calendar.Event eventItem) =>
string.IsNullOrEmpty(eventItem.MeetingUrl) ? eventItem.Summary : $"[{eventItem.Summary}]({eventItem.MeetingUrl})";
- private static void Month(bool nextMonth)
+ private static void Month(DateOnly start, DateOnly end)
{
- (DateOnly start, DateOnly end) = GetMonthRange(nextMonth);
-
AnsiConsoleHelper.TitleRule($":calendar: {start:MMMM yyyy}");
var table = new Table();
@@ -313,9 +316,8 @@ private static void Month(bool nextMonth)
AnsiConsoleHelper.Rule("white");
}
- private static async Task MonthMarkdown(bool nextMonth)
+ private static async Task MonthMarkdown(DateOnly start, DateOnly end)
{
- (DateOnly start, DateOnly end) = GetMonthRange(nextMonth);
StringBuilder cal = new();
cal.AppendLine("| Day | Date | Habits | Notes |");
cal.AppendLine("| --- | ---- | ------ | ----- |");
@@ -336,9 +338,9 @@ private static async Task MonthMarkdown(bool nextMonth)
AnsiConsoleHelper.Rule("white");
}
- private static (DateOnly start, DateOnly end) GetMonthRange(bool nextMonth)
+ private static (DateOnly start, DateOnly end) GetMonthRange(int addMonths)
{
- var now = nextMonth ? DateTime.Now.AddMonths(1) : DateTime.Now;
+ var now = DateTime.Now.AddMonths(addMonths);
var start = new DateOnly(now.Year, now.Month, 1);
var end = new DateOnly(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month));
return (start, end);
diff --git a/dotnet-todo b/dotnet-todo
index ae2c43a..cefe4fb 160000
--- a/dotnet-todo
+++ b/dotnet-todo
@@ -1 +1 @@
-Subproject commit ae2c43acae324f39d781b794cc8062c48badc65b
+Subproject commit cefe4fb5a350040af4d03e9babad54428ced253f