Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ dist/
*.log
.DS_Store
.claude/
client_secrets/

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 32 additions & 15 deletions src/commands/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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) {
Expand All @@ -50,9 +55,13 @@ export function registerCalendarCommands(program: Command): void {
.option('--calendar <id>', 'Calendar ID to query', 'primary')
.option('--limit <number>', '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);

Expand All @@ -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) {
Expand All @@ -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);

Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down