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..4da9897 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.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);