diff --git a/README.md b/README.md index 8a687ff..109ed6d 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,10 @@ The `export` flag is optional - when set to true, a JSON file with the raw data ### Day Log ``` -daylog -text "text" -date "date" +daylog -stars number -text "text" -date "date" ``` -Example: `daylog -text "Meeting notes or daily summary" -date "2024-01-18"` +Example: `daylog -stars 3 -text "Meeting notes or daily summary" -date "2024-01-18"` Adds a log entry for a specific day. The date parameter is optional and defaults to the current date. diff --git a/app/page.tsx b/app/page.tsx index bca059d..e32638c 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -6,7 +6,7 @@ export default function Home() { const commands = [ 'expense add -desc "Coffee" -cost 3.50 -cat "Food"', 'expense report -from "2024-01-01" -to "2024-01-31"', - 'expense daylog -text "Added team lunch" -date "2024-01-18"' + 'expense daylog -stars 3 -text "Added team lunch" -date "2024-01-18"' ]; return ( diff --git a/utils/commands/diary.ts b/utils/commands/diary.ts index 2a8e704..43dde42 100644 --- a/utils/commands/diary.ts +++ b/utils/commands/diary.ts @@ -130,10 +130,11 @@ export async function diaryCommand( } case 'daylog': { + const stars = parsedCommand.flags.stars as number; const text = parsedCommand.flags.text as string; const date = (parsedCommand.flags.date as Date) || new Date(); - return processDayLog(text, date); + return processDayLog(stars, text, date); } default: diff --git a/utils/commands/helpers/commandParser.ts b/utils/commands/helpers/commandParser.ts index 7b09b2d..af05d9b 100644 --- a/utils/commands/helpers/commandParser.ts +++ b/utils/commands/helpers/commandParser.ts @@ -141,6 +141,7 @@ export const diaryCommands: CommandDefinition[] = [ { name: 'daylog', flags: [ + { name: 'stars', type: 'number', required: true }, { name: 'text', type: 'string', required: true }, { name: 'date', type: 'date', required: false } ] diff --git a/utils/commands/helpers/dayLog.ts b/utils/commands/helpers/dayLog.ts index 727fa08..678c96d 100644 --- a/utils/commands/helpers/dayLog.ts +++ b/utils/commands/helpers/dayLog.ts @@ -3,6 +3,7 @@ import prisma from '@prisma/prisma'; import { ShortcutsResponse } from '@utils/types'; export async function processDayLog( + stars: number, text: string, date?: Date ): Promise { @@ -11,6 +12,7 @@ export async function processDayLog( normalizedDate.setUTCHours(0, 0, 0, 0); const newComment: Prisma.JsonObject = { + stars, text, timestamp: new Date().toISOString() }; diff --git a/utils/commands/report.ts b/utils/commands/report.ts index 41a40bb..5bcfb94 100644 --- a/utils/commands/report.ts +++ b/utils/commands/report.ts @@ -200,6 +200,7 @@ export class ExpenseReporter { ID Date + Stars Log ${dayLogs.dayLogs @@ -213,6 +214,7 @@ export class ExpenseReporter { ${dl.id} ${formatDate(dl.createdAt)} + ${'✪'.repeat(comment.stars)} ${comment.text} `