From b5b0f130545efec7f488f06bdba443fbb077f114 Mon Sep 17 00:00:00 2001 From: "D.H. Luong" <21980965+jarvisluong@users.noreply.github.com> Date: Sat, 14 Mar 2026 23:49:06 +0200 Subject: [PATCH 1/2] fix(calendar): honor global --profile and --format flags Read global CLI options in calendar subcommands so profile selection and output format work consistently with the rest of gwcli. This prevents calendar commands from silently falling back to the default profile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .gitignore | 2 ++ package-lock.json | 4 ++-- src/commands/calendar.ts | 47 +++++++++++++++++++++++++++------------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 8267a39..fbedd18 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ dist/ *.log .DS_Store .claude/ +client_secrets/ + diff --git a/package-lock.json b/package-lock.json index 567a291..a208afb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "gwcli", + "name": "google-workspace-cli", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "gwcli", + "name": "google-workspace-cli", "version": "0.1.0", "license": "MIT", "dependencies": { diff --git a/src/commands/calendar.ts b/src/commands/calendar.ts index 70857e7..5eebefe 100644 --- a/src/commands/calendar.ts +++ b/src/commands/calendar.ts @@ -11,6 +11,10 @@ import { } from '../lib/output.js'; import type { GlobalOptions } from '../types/index.js'; +function getCalendarGlobalOptions(command: Command): GlobalOptions { + return command.parent?.optsWithGlobals() as GlobalOptions; +} + /** * Register all calendar subcommands */ @@ -23,14 +27,15 @@ export function registerCalendarCommands(program: Command): void { calendar .command('list') .description('List all calendars') - .action(async (options: GlobalOptions) => { + .action(async (_options: GlobalOptions, command: Command) => { try { - const profileName = getActiveProfile(options.profile); + const globalOptions = getCalendarGlobalOptions(command); + const profileName = getActiveProfile(globalOptions.profile); const auth = await getAuthenticatedClient(profileName); const client = new CalendarClient(auth); const calendars = await client.listCalendars(); - const format = options.format || 'table'; + const format = globalOptions.format || 'table'; const output = formatCalendarList(calendars, format); print(output); } catch (error) { @@ -50,9 +55,13 @@ export function registerCalendarCommands(program: Command): void { .option('--calendar ', 'Calendar ID to query', 'primary') .option('--limit ', 'Maximum number of events to return', '10') .action( - async (options: GlobalOptions & { days: string; calendar: string; limit: string }) => { + async ( + options: GlobalOptions & { days: string; calendar: string; limit: string }, + command: Command + ) => { try { - const profileName = getActiveProfile(options.profile); + const globalOptions = getCalendarGlobalOptions(command); + const profileName = getActiveProfile(globalOptions.profile); const auth = await getAuthenticatedClient(profileName); const client = new CalendarClient(auth); @@ -62,7 +71,7 @@ export function registerCalendarCommands(program: Command): void { maxResults: parseInt(options.limit, 10), }); - const format = options.format || 'table'; + const format = globalOptions.format || 'table'; const output = formatEventList(events, format); print(output); } catch (error) { @@ -84,10 +93,12 @@ export function registerCalendarCommands(program: Command): void { .action( async ( query: string, - options: GlobalOptions & { days: string; calendar: string } + options: GlobalOptions & { days: string; calendar: string }, + command: Command ) => { try { - const profileName = getActiveProfile(options.profile); + const globalOptions = getCalendarGlobalOptions(command); + const profileName = getActiveProfile(globalOptions.profile); const auth = await getAuthenticatedClient(profileName); const client = new CalendarClient(auth); @@ -96,7 +107,7 @@ export function registerCalendarCommands(program: Command): void { days: parseInt(options.days, 10), }); - const format = options.format || 'table'; + const format = globalOptions.format || 'table'; const output = formatEventList(events, format); print(output); } catch (error) { @@ -129,10 +140,12 @@ export function registerCalendarCommands(program: Command): void { description?: string; location?: string; attendees?: string; - } + }, + command: Command ) => { try { - const profileName = getActiveProfile(options.profile); + const globalOptions = getCalendarGlobalOptions(command); + const profileName = getActiveProfile(globalOptions.profile); const auth = await getAuthenticatedClient(profileName); const client = new CalendarClient(auth); @@ -181,10 +194,12 @@ export function registerCalendarCommands(program: Command): void { description?: string; location?: string; calendar: string; - } + }, + command: Command ) => { try { - const profileName = getActiveProfile(options.profile); + const globalOptions = getCalendarGlobalOptions(command); + const profileName = getActiveProfile(globalOptions.profile); const auth = await getAuthenticatedClient(profileName); const client = new CalendarClient(auth); @@ -216,10 +231,12 @@ export function registerCalendarCommands(program: Command): void { .action( async ( eventId: string, - options: GlobalOptions & { calendar: string } + options: GlobalOptions & { calendar: string }, + command: Command ) => { try { - const profileName = getActiveProfile(options.profile); + const globalOptions = getCalendarGlobalOptions(command); + const profileName = getActiveProfile(globalOptions.profile); const auth = await getAuthenticatedClient(profileName); const client = new CalendarClient(auth); From 75875afae01d6ed8359c8087a97f1c97a6002b2f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Mar 2026 22:08:46 +0000 Subject: [PATCH 2/2] fix(calendar): use command.optsWithGlobals() directly to avoid undefined and recursive concerns Co-authored-by: jarvisluong <21980965+jarvisluong@users.noreply.github.com> --- src/commands/calendar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/calendar.ts b/src/commands/calendar.ts index 5eebefe..4da9897 100644 --- a/src/commands/calendar.ts +++ b/src/commands/calendar.ts @@ -12,7 +12,7 @@ import { import type { GlobalOptions } from '../types/index.js'; function getCalendarGlobalOptions(command: Command): GlobalOptions { - return command.parent?.optsWithGlobals() as GlobalOptions; + return command.optsWithGlobals() as GlobalOptions; } /**