@ncukondo/gcal-cli 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +183 -168
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -587668,6 +587668,24 @@ function formatSearchResultText(query, events) {
587668
587668
  return lines.join(`
587669
587669
  `);
587670
587670
  }
587671
+ function formatQuietText(events) {
587672
+ if (events.length === 0)
587673
+ return "No events found.";
587674
+ const lines = [];
587675
+ for (const event of events) {
587676
+ const month = event.start.slice(5, 7);
587677
+ const day = event.start.slice(8, 10);
587678
+ const datePrefix = `${month}/${day}`;
587679
+ if (event.all_day) {
587680
+ lines.push(`${datePrefix} All day ${event.title}`);
587681
+ } else {
587682
+ const time3 = formatTimeRange(event);
587683
+ lines.push(`${datePrefix} ${time3} ${event.title}`);
587684
+ }
587685
+ }
587686
+ return lines.join(`
587687
+ `);
587688
+ }
587671
587689
  var CALENDAR_ID_MAX = 15;
587672
587690
  var CALENDAR_ID_COL = 18;
587673
587691
  function truncateId(id) {
@@ -587736,7 +587754,7 @@ function errorCodeToExitCode(code) {
587736
587754
  // package.json
587737
587755
  var package_default = {
587738
587756
  name: "@ncukondo/gcal-cli",
587739
- version: "0.3.0",
587757
+ version: "0.4.0",
587740
587758
  type: "module",
587741
587759
  exports: {
587742
587760
  ".": "./dist/index.js"
@@ -587790,12 +587808,9 @@ var package_default = {
587790
587808
 
587791
587809
  // src/cli.ts
587792
587810
  var FormatSchema = _enum(["text", "json"]);
587793
- function collect(value, previous) {
587794
- return [...previous, value];
587795
- }
587796
587811
  function createProgram() {
587797
587812
  const program2 = new Command;
587798
- program2.name("gcal").description("CLI tool for managing Google Calendar events").version(package_default.version).option("-f, --format <format>", "Output format: text | json", "text").option("-c, --calendar <id>", "Target calendar ID (repeatable)", collect, []).option("-q, --quiet", "Minimal output", false).option("--tz, --timezone <zone>", "Timezone (e.g., Asia/Tokyo)");
587813
+ program2.name("gcal").description("CLI tool for managing Google Calendar events").version(package_default.version).option("-f, --format <format>", "Output format: text | json", "text").option("-q, --quiet", "Minimal output", false).option("--tz, --timezone <zone>", "Timezone (e.g., Asia/Tokyo)");
587799
587814
  program2.on("command:*", (operands) => {
587800
587815
  process.stderr.write(`error: unknown command '${operands[0]}'
587801
587816
 
@@ -587815,7 +587830,6 @@ function resolveGlobalOptions(program2) {
587815
587830
  }
587816
587831
  return {
587817
587832
  format: formatResult.data,
587818
- calendar: raw.calendar,
587819
587833
  timezone: raw.timezone,
587820
587834
  quiet: raw.quiet
587821
587835
  };
@@ -588424,6 +588438,61 @@ function applyFilters(events, options) {
588424
588438
  const afterTransparency = filterByTransparency(events, options.transparency);
588425
588439
  return filterByStatus(afterTransparency, options);
588426
588440
  }
588441
+
588442
+ // src/commands/shared.ts
588443
+ import * as nodeFs from "node:fs";
588444
+ var fsAdapter = {
588445
+ existsSync: (p) => nodeFs.existsSync(p),
588446
+ readFileSync: (p) => nodeFs.readFileSync(p, "utf-8"),
588447
+ writeFileSync: (p, d) => nodeFs.writeFileSync(p, d, "utf-8"),
588448
+ mkdirSync: (p) => nodeFs.mkdirSync(p, { recursive: true }),
588449
+ unlinkSync: (p) => nodeFs.unlinkSync(p),
588450
+ chmodSync: (p, m) => nodeFs.chmodSync(p, m)
588451
+ };
588452
+ function collect(value, previous) {
588453
+ return [...previous, value];
588454
+ }
588455
+ function createGoogleCalendarApi(calendar) {
588456
+ return {
588457
+ calendarList: {
588458
+ list: async (p) => {
588459
+ const res = await calendar.calendarList.list(p);
588460
+ const data = {};
588461
+ if (res.data.items)
588462
+ data.items = res.data.items;
588463
+ if (res.data.nextPageToken)
588464
+ data.nextPageToken = res.data.nextPageToken;
588465
+ return { data };
588466
+ }
588467
+ },
588468
+ events: {
588469
+ list: async (p) => {
588470
+ const res = await calendar.events.list(p);
588471
+ const data = {};
588472
+ if (res.data.items)
588473
+ data.items = res.data.items;
588474
+ if (res.data.nextPageToken)
588475
+ data.nextPageToken = res.data.nextPageToken;
588476
+ return { data };
588477
+ },
588478
+ get: async (p) => {
588479
+ const res = await calendar.events.get(p);
588480
+ return { data: res.data };
588481
+ },
588482
+ insert: async (p) => {
588483
+ const res = await calendar.events.insert(p);
588484
+ return { data: res.data };
588485
+ },
588486
+ patch: async (p) => {
588487
+ const res = await calendar.events.patch(p);
588488
+ return { data: res.data };
588489
+ },
588490
+ delete: async (p) => {
588491
+ await calendar.events.delete(p);
588492
+ }
588493
+ }
588494
+ };
588495
+ }
588427
588496
  // node_modules/date-fns/locale/en-US/_lib/formatDistance.mjs
588428
588497
  var formatDistanceLocale = {
588429
588498
  lessThanXSeconds: {
@@ -590596,8 +590665,8 @@ function parseDateTimeInZone(dateStr, timezone) {
590596
590665
  // src/commands/search.ts
590597
590666
  var DEFAULT_SEARCH_DAYS = 30;
590598
590667
  async function handleSearch(opts) {
590599
- const { api: api2, query, format: format4, calendars, timezone, write } = opts;
590600
- const writeErr = opts.writeErr ?? (() => {});
590668
+ const { api: api2, query, format: format4, calendars, timezone, write, quiet } = opts;
590669
+ const writeErr = quiet ? () => {} : opts.writeErr ?? (() => {});
590601
590670
  const now = new Date;
590602
590671
  const days = opts.days ?? DEFAULT_SEARCH_DAYS;
590603
590672
  const isNegativeDays = days < 0;
@@ -590605,7 +590674,7 @@ async function handleSearch(opts) {
590605
590674
  let timeMax;
590606
590675
  if (opts.from && opts.to) {
590607
590676
  timeMin = formatDateTimeInZone(parseDateTimeInZone(opts.from, timezone), timezone);
590608
- timeMax = formatDateTimeInZone(parseDateTimeInZone(opts.to + "T23:59:59", timezone), timezone);
590677
+ timeMax = formatDateTimeInZone(addDays(parseDateTimeInZone(opts.to, timezone), 1), timezone);
590609
590678
  } else if (opts.from) {
590610
590679
  const startDate = parseDateTimeInZone(opts.from, timezone);
590611
590680
  timeMin = formatDateTimeInZone(startDate, timezone);
@@ -590613,7 +590682,7 @@ async function handleSearch(opts) {
590613
590682
  endDate.setDate(endDate.getDate() + days);
590614
590683
  timeMax = formatDateTimeInZone(endDate, timezone);
590615
590684
  } else if (opts.to) {
590616
- timeMax = formatDateTimeInZone(parseDateTimeInZone(opts.to + "T23:59:59", timezone), timezone);
590685
+ timeMax = formatDateTimeInZone(addDays(parseDateTimeInZone(opts.to, timezone), 1), timezone);
590617
590686
  timeMin = formatDateTimeInZone(now, timezone);
590618
590687
  } else if (isNegativeDays) {
590619
590688
  const pastDate = new Date(now.getTime());
@@ -590627,7 +590696,7 @@ async function handleSearch(opts) {
590627
590696
  timeMax = formatDateTimeInZone(endDate, timezone);
590628
590697
  }
590629
590698
  const displayFrom = timeMin.slice(0, 10);
590630
- const displayTo = timeMax.slice(0, 10);
590699
+ const displayTo = opts.to ?? timeMax.slice(0, 10);
590631
590700
  writeErr(`Searching: ${displayFrom} to ${displayTo}`);
590632
590701
  const hasExplicitRange = opts.days !== undefined || opts.from !== undefined || opts.to !== undefined;
590633
590702
  if (!hasExplicitRange) {
@@ -590648,6 +590717,8 @@ async function handleSearch(opts) {
590648
590717
  events: filtered,
590649
590718
  count: filtered.length
590650
590719
  }));
590720
+ } else if (quiet) {
590721
+ write(formatQuietText(filtered));
590651
590722
  } else {
590652
590723
  write(formatSearchResultText(query, filtered));
590653
590724
  }
@@ -590655,9 +590726,10 @@ async function handleSearch(opts) {
590655
590726
  }
590656
590727
  function createSearchCommand() {
590657
590728
  const cmd = new Command("search").description("Search events by keyword").argument("<query>", "Search query string");
590729
+ cmd.option("-c, --calendar <id>", "Target calendar ID (repeatable)", collect, []);
590658
590730
  cmd.option("--from <date>", "Start date for search range");
590659
590731
  cmd.option("--to <date>", "End date for search range");
590660
- cmd.option("--days <n>", "Search within next n days (default: 30)", Number.parseInt);
590732
+ cmd.option("--days <n>", "Search within next n days (default: 30)", (v) => Number.parseInt(v, 10));
590661
590733
  const daysOpt = cmd.options.find((o) => o.long === "--days");
590662
590734
  const fromOpt = cmd.options.find((o) => o.long === "--from");
590663
590735
  const toOpt = cmd.options.find((o) => o.long === "--to");
@@ -590667,32 +590739,26 @@ function createSearchCommand() {
590667
590739
  cmd.option("--busy", "Show only busy (opaque) events");
590668
590740
  cmd.option("--free", "Show only free (transparent) events");
590669
590741
  cmd.option("--confirmed", "Show only confirmed events");
590670
- cmd.option("--include-tentative", "Include tentative events");
590742
+ cmd.option("--include-tentative", "Include tentative events (excluded by default)");
590743
+ const busyOpt = cmd.options.find((o) => o.long === "--busy");
590744
+ const freeOpt = cmd.options.find((o) => o.long === "--free");
590745
+ busyOpt.conflicts(["free"]);
590746
+ freeOpt.conflicts(["busy"]);
590671
590747
  return cmd;
590672
590748
  }
590673
590749
 
590674
590750
  // src/commands/show.ts
590675
590751
  async function handleShow(opts) {
590676
- const { api: api2, eventId, calendarId, calendarName, format: format4, timezone, write } = opts;
590677
- try {
590678
- const event = await getEvent(api2, calendarId, calendarName, eventId, timezone);
590679
- if (format4 === "json") {
590680
- write(formatJsonSuccess({ event }));
590681
- } else {
590682
- write(formatEventDetailText(event));
590683
- }
590684
- return { exitCode: ExitCode.SUCCESS };
590685
- } catch (error) {
590686
- if (error instanceof ApiError) {
590687
- if (format4 === "json") {
590688
- write(formatJsonError(error.code, error.message));
590689
- } else {
590690
- write(`Error: ${error.message}`);
590691
- }
590692
- return { exitCode: errorCodeToExitCode(error.code) };
590693
- }
590694
- throw error;
590752
+ const { api: api2, eventId, calendarId, calendarName, format: format4, quiet, timezone, write } = opts;
590753
+ const event = await getEvent(api2, calendarId, calendarName, eventId, timezone);
590754
+ if (format4 === "json") {
590755
+ write(formatJsonSuccess({ event }));
590756
+ } else if (quiet) {
590757
+ write(`${event.title} ${event.start} ${event.end}`);
590758
+ } else {
590759
+ write(formatEventDetailText(event));
590695
590760
  }
590761
+ return { exitCode: ExitCode.SUCCESS };
590696
590762
  }
590697
590763
  function createShowCommand() {
590698
590764
  return new Command("show").description("Show event details").argument("<event-id>", "Event ID").option("-c, --calendar <id>", "Calendar ID to query");
@@ -591778,24 +591844,6 @@ function resolveDateRange(input, timezone, now = () => new Date) {
591778
591844
  timeMax: formatDateTimeInZone(end, timezone)
591779
591845
  };
591780
591846
  }
591781
- function formatQuietText(events) {
591782
- if (events.length === 0)
591783
- return "No events found.";
591784
- const lines = [];
591785
- for (const event of events) {
591786
- const month = event.start.slice(5, 7);
591787
- const day = event.start.slice(8, 10);
591788
- const datePrefix = `${month}/${day}`;
591789
- if (event.all_day) {
591790
- lines.push(`${datePrefix} All day ${event.title}`);
591791
- } else {
591792
- const time3 = formatTimeRange(event);
591793
- lines.push(`${datePrefix} ${time3} ${event.title}`);
591794
- }
591795
- }
591796
- return lines.join(`
591797
- `);
591798
- }
591799
591847
  async function handleList(options, deps) {
591800
591848
  const config2 = deps.loadConfig();
591801
591849
  const timezone = resolveTimezone(options.timezone, config2.timezone);
@@ -591813,7 +591861,7 @@ async function handleList(options, deps) {
591813
591861
  if (dateRange.warning && deps.writeErr) {
591814
591862
  deps.writeErr(dateRange.warning);
591815
591863
  }
591816
- const calendars = selectCalendars(options.calendar, config2);
591864
+ const calendars = selectCalendars(options.calendar && options.calendar.length > 0 ? options.calendar : undefined, config2);
591817
591865
  const apiOptions = {
591818
591866
  timeMin: dateRange.timeMin,
591819
591867
  timeMax: dateRange.timeMax
@@ -591852,6 +591900,7 @@ async function handleList(options, deps) {
591852
591900
  }
591853
591901
  function createListCommand() {
591854
591902
  const cmd = new Command("list").description("List events within a date range");
591903
+ cmd.option("-c, --calendar <id>", "Target calendar ID (repeatable)", collect, []);
591855
591904
  cmd.option("--today", "Show today's events");
591856
591905
  cmd.option("--days <n>", "Events for next n days (default: 7)", (v) => Number.parseInt(v, 10));
591857
591906
  cmd.option("--from <date>", "Start date (ISO 8601 or YYYY-MM-DD)");
@@ -591865,9 +591914,11 @@ function createListCommand() {
591865
591914
  const fromOpt = cmd.options.find((o) => o.long === "--from");
591866
591915
  const busyOpt = cmd.options.find((o) => o.long === "--busy");
591867
591916
  const freeOpt = cmd.options.find((o) => o.long === "--free");
591917
+ const toOpt = cmd.options.find((o) => o.long === "--to");
591868
591918
  todayOpt.conflicts(["days", "from"]);
591869
- daysOpt.conflicts(["today", "from"]);
591919
+ daysOpt.conflicts(["today", "from", "to"]);
591870
591920
  fromOpt.conflicts(["today", "days"]);
591921
+ toOpt.conflicts(["days"]);
591871
591922
  busyOpt.conflicts(["free"]);
591872
591923
  freeOpt.conflicts(["busy"]);
591873
591924
  return cmd;
@@ -592133,9 +592184,14 @@ async function handleUpdate(opts) {
592133
592184
  }
592134
592185
  const updated = await updateEvent(api2, calendarId, calendarName, eventId, input);
592135
592186
  if (format4 === "json") {
592136
- write(formatJsonSuccess({ event: updated }));
592187
+ write(formatJsonSuccess({ event: updated, message: "Event updated" }));
592188
+ } else if (opts.quiet) {
592189
+ write(updated.id);
592137
592190
  } else {
592138
- write(formatEventDetailText(updated));
592191
+ const detail = formatEventDetailText(updated);
592192
+ write(`Event updated
592193
+
592194
+ ${detail}`);
592139
592195
  }
592140
592196
  return { exitCode: ExitCode.SUCCESS };
592141
592197
  }
@@ -592261,9 +592317,37 @@ async function handleAdd(options, deps) {
592261
592317
  if (options.description !== undefined) {
592262
592318
  input.description = options.description;
592263
592319
  }
592320
+ if (options.dryRun) {
592321
+ const preview = {
592322
+ title: input.title,
592323
+ start: input.start,
592324
+ end: input.end
592325
+ };
592326
+ if (input.description !== undefined)
592327
+ preview.description = input.description;
592328
+ if (input.transparency !== "opaque")
592329
+ preview.transparency = input.transparency;
592330
+ if (options.format === "json") {
592331
+ deps.write(formatJsonSuccess({ dry_run: true, action: "add", event: preview }));
592332
+ } else {
592333
+ const lines = ["DRY RUN: Would create event:"];
592334
+ lines.push(` title: "${preview.title}"`);
592335
+ lines.push(` start: "${preview.start}"`);
592336
+ lines.push(` end: "${preview.end}"`);
592337
+ if (preview.description !== undefined)
592338
+ lines.push(` description: "${preview.description}"`);
592339
+ if (preview.transparency !== undefined)
592340
+ lines.push(` transparency: ${preview.transparency}`);
592341
+ deps.write(lines.join(`
592342
+ `));
592343
+ }
592344
+ return { exitCode: ExitCode.SUCCESS };
592345
+ }
592264
592346
  const event = await deps.createEvent(calendarId, calendarName, input);
592265
592347
  if (options.format === "json") {
592266
592348
  deps.write(formatJsonSuccess({ event, message: "Event created" }));
592349
+ } else if (options.quiet) {
592350
+ deps.write(event.id);
592267
592351
  } else {
592268
592352
  const detail = formatEventDetailText(event);
592269
592353
  deps.write(`Event created
@@ -592278,9 +592362,11 @@ function createAddCommand() {
592278
592362
  cmd.requiredOption("-s, --start <datetime>", "Start date or datetime. Date-only (YYYY-MM-DD) creates all-day event. Datetime (YYYY-MM-DDTHH:MM) creates timed event.");
592279
592363
  cmd.option("-e, --end <datetime>", "End date or datetime. Optional. Default: same day (all-day) or +1h (timed). All-day end is inclusive.");
592280
592364
  cmd.option("--duration <duration>", "Duration instead of --end (e.g. 30m, 1h, 2d, 1h30m). Mutually exclusive with --end.");
592365
+ cmd.option("-c, --calendar <id>", "Target calendar ID");
592281
592366
  cmd.option("-d, --description <text>", "Event description");
592282
592367
  cmd.option("--busy", "Mark as busy (default)");
592283
592368
  cmd.option("--free", "Mark as free (transparent)");
592369
+ cmd.option("--dry-run", "Preview without executing");
592284
592370
  const endOpt = cmd.options.find((o) => o.long === "--end");
592285
592371
  const durationOpt = cmd.options.find((o) => o.long === "--duration");
592286
592372
  endOpt.conflicts(["duration"]);
@@ -592306,8 +592392,7 @@ Examples:
592306
592392
  async function handleDelete(opts) {
592307
592393
  const { api: api2, eventId, calendarId, format: format4, quiet, dryRun = false, write } = opts;
592308
592394
  if (!eventId) {
592309
- write(formatJsonError("INVALID_ARGS", "event-id is required"));
592310
- return { exitCode: ExitCode.ARGUMENT };
592395
+ throw new ApiError("INVALID_ARGS", "event-id is required");
592311
592396
  }
592312
592397
  if (dryRun) {
592313
592398
  if (format4 === "json") {
@@ -592322,27 +592407,15 @@ async function handleDelete(opts) {
592322
592407
  }
592323
592408
  return { exitCode: ExitCode.SUCCESS };
592324
592409
  }
592325
- try {
592326
- await deleteEvent(api2, calendarId, eventId);
592327
- if (!quiet) {
592328
- if (format4 === "json") {
592329
- write(formatJsonSuccess({ deleted_id: eventId, message: "Event deleted" }));
592330
- } else {
592331
- write("Event deleted");
592332
- }
592333
- }
592334
- return { exitCode: ExitCode.SUCCESS };
592335
- } catch (error) {
592336
- if (error instanceof ApiError) {
592337
- if (format4 === "json") {
592338
- write(formatJsonError(error.code, error.message));
592339
- } else {
592340
- write(`Error: ${error.message}`);
592341
- }
592342
- return { exitCode: errorCodeToExitCode(error.code) };
592410
+ await deleteEvent(api2, calendarId, eventId);
592411
+ if (!quiet) {
592412
+ if (format4 === "json") {
592413
+ write(formatJsonSuccess({ deleted_id: eventId, message: "Event deleted" }));
592414
+ } else {
592415
+ write("Event deleted");
592343
592416
  }
592344
- throw error;
592345
592417
  }
592418
+ return { exitCode: ExitCode.SUCCESS };
592346
592419
  }
592347
592420
  function createDeleteCommand() {
592348
592421
  return new Command("delete").description("Delete a calendar event").argument("<event-id>", "Event ID").option("-c, --calendar <id>", "Calendar ID to query").option("--dry-run", "Preview without executing");
@@ -592361,20 +592434,7 @@ function mergeCalendarsWithConfig(apiCalendars, configCalendars) {
592361
592434
  }
592362
592435
  async function handleCalendars(opts) {
592363
592436
  const { api: api2, format: format4, quiet, write, configCalendars } = opts;
592364
- let apiCalendars;
592365
- try {
592366
- apiCalendars = await listCalendars(api2);
592367
- } catch (error) {
592368
- if (error instanceof ApiError) {
592369
- if (format4 === "json") {
592370
- write(formatJsonError(error.code, error.message));
592371
- } else {
592372
- write(error.message);
592373
- }
592374
- return { exitCode: errorCodeToExitCode(error.code) };
592375
- }
592376
- throw error;
592377
- }
592437
+ const apiCalendars = await listCalendars(api2);
592378
592438
  const calendars = mergeCalendarsWithConfig(apiCalendars, configCalendars);
592379
592439
  if (quiet) {
592380
592440
  write(calendars.map((c) => c.id).join(`
@@ -592486,58 +592546,6 @@ function createInitCommand() {
592486
592546
  return cmd;
592487
592547
  }
592488
592548
 
592489
- // src/commands/shared.ts
592490
- import * as nodeFs from "node:fs";
592491
- var fsAdapter = {
592492
- existsSync: (p) => nodeFs.existsSync(p),
592493
- readFileSync: (p) => nodeFs.readFileSync(p, "utf-8"),
592494
- writeFileSync: (p, d) => nodeFs.writeFileSync(p, d, "utf-8"),
592495
- mkdirSync: (p) => nodeFs.mkdirSync(p, { recursive: true }),
592496
- unlinkSync: (p) => nodeFs.unlinkSync(p),
592497
- chmodSync: (p, m) => nodeFs.chmodSync(p, m)
592498
- };
592499
- function createGoogleCalendarApi(calendar) {
592500
- return {
592501
- calendarList: {
592502
- list: async (p) => {
592503
- const res = await calendar.calendarList.list(p);
592504
- const data = {};
592505
- if (res.data.items)
592506
- data.items = res.data.items;
592507
- if (res.data.nextPageToken)
592508
- data.nextPageToken = res.data.nextPageToken;
592509
- return { data };
592510
- }
592511
- },
592512
- events: {
592513
- list: async (p) => {
592514
- const res = await calendar.events.list(p);
592515
- const data = {};
592516
- if (res.data.items)
592517
- data.items = res.data.items;
592518
- if (res.data.nextPageToken)
592519
- data.nextPageToken = res.data.nextPageToken;
592520
- return { data };
592521
- },
592522
- get: async (p) => {
592523
- const res = await calendar.events.get(p);
592524
- return { data: res.data };
592525
- },
592526
- insert: async (p) => {
592527
- const res = await calendar.events.insert(p);
592528
- return { data: res.data };
592529
- },
592530
- patch: async (p) => {
592531
- const res = await calendar.events.patch(p);
592532
- return { data: res.data };
592533
- },
592534
- delete: async (p) => {
592535
- await calendar.events.delete(p);
592536
- }
592537
- }
592538
- };
592539
- }
592540
-
592541
592549
  // src/cli.ts
592542
592550
  var FormatSchema2 = _enum(["text", "json"]);
592543
592551
  function resolveGlobalOptions2(program2) {
@@ -592550,7 +592558,6 @@ function resolveGlobalOptions2(program2) {
592550
592558
  }
592551
592559
  return {
592552
592560
  format: formatResult.data,
592553
- calendar: raw.calendar,
592554
592561
  timezone: raw.timezone,
592555
592562
  quiet: raw.quiet
592556
592563
  };
@@ -592663,19 +592670,23 @@ ${url}`);
592663
592670
  const calendarsCmd = createCalendarsCommand();
592664
592671
  calendarsCmd.action(async () => {
592665
592672
  const globalOpts = resolveGlobalOptions2(program2);
592666
- const config2 = loadConfig(fsAdapter);
592667
- const oauth2Client = await getAuthenticatedClient(fsAdapter);
592668
- const calendar = import_googleapis2.google.calendar({ version: "v3", auth: oauth2Client });
592669
- const api2 = createGoogleCalendarApi(calendar);
592670
- const result = await handleCalendars({
592671
- api: api2,
592672
- format: globalOpts.format,
592673
- quiet: globalOpts.quiet,
592674
- write: (msg) => process.stdout.write(msg + `
592673
+ try {
592674
+ const config2 = loadConfig(fsAdapter);
592675
+ const oauth2Client = await getAuthenticatedClient(fsAdapter);
592676
+ const calendar = import_googleapis2.google.calendar({ version: "v3", auth: oauth2Client });
592677
+ const api2 = createGoogleCalendarApi(calendar);
592678
+ const result = await handleCalendars({
592679
+ api: api2,
592680
+ format: globalOpts.format,
592681
+ quiet: globalOpts.quiet,
592682
+ write: (msg) => process.stdout.write(msg + `
592675
592683
  `),
592676
- configCalendars: config2.calendars
592677
- });
592678
- process.exit(result.exitCode);
592684
+ configCalendars: config2.calendars
592685
+ });
592686
+ process.exit(result.exitCode);
592687
+ } catch (error) {
592688
+ handleError2(error, globalOpts.format);
592689
+ }
592679
592690
  });
592680
592691
  program2.addCommand(calendarsCmd);
592681
592692
  const listCmd = createListCommand();
@@ -592684,7 +592695,7 @@ ${url}`);
592684
592695
  const listOpts = listCmd.opts();
592685
592696
  try {
592686
592697
  const auth = await getAuthenticatedClient(fsAdapter);
592687
- const api2 = import_googleapis2.google.calendar({ version: "v3", auth });
592698
+ const api2 = createGoogleCalendarApi(import_googleapis2.google.calendar({ version: "v3", auth }));
592688
592699
  const deps = {
592689
592700
  listEvents: (calendarId, calendarName, options) => listEvents(api2, calendarId, calendarName, options),
592690
592701
  loadConfig: () => loadConfig(fsAdapter),
@@ -592696,8 +592707,7 @@ ${url}`);
592696
592707
  const handleOpts = {
592697
592708
  ...listOpts,
592698
592709
  format: globalOpts.format,
592699
- quiet: globalOpts.quiet,
592700
- calendar: globalOpts.calendar
592710
+ quiet: globalOpts.quiet
592701
592711
  };
592702
592712
  if (globalOpts.timezone)
592703
592713
  handleOpts.timezone = globalOpts.timezone;
@@ -592718,11 +592728,12 @@ ${url}`);
592718
592728
  const calendarApi = import_googleapis2.google.calendar({ version: "v3", auth });
592719
592729
  const api2 = createGoogleCalendarApi(calendarApi);
592720
592730
  const timezone = resolveTimezone(globalOpts.timezone, config2.timezone);
592721
- const calendars = selectCalendars(globalOpts.calendar, config2);
592731
+ const calendars = selectCalendars(searchOpts.calendar.length > 0 ? searchOpts.calendar : undefined, config2);
592722
592732
  const result = await handleSearch({
592723
592733
  api: api2,
592724
592734
  query,
592725
592735
  format: globalOpts.format,
592736
+ quiet: globalOpts.quiet,
592726
592737
  calendars,
592727
592738
  timezone,
592728
592739
  days: searchOpts.days,
@@ -592744,7 +592755,7 @@ ${url}`);
592744
592755
  });
592745
592756
  program2.addCommand(searchCmd);
592746
592757
  const showCmd = createShowCommand();
592747
- showCmd.action(async () => {
592758
+ showCmd.action(async (eventId) => {
592748
592759
  const globalOpts = resolveGlobalOptions2(program2);
592749
592760
  const showOpts = showCmd.opts();
592750
592761
  try {
@@ -592752,23 +592763,24 @@ ${url}`);
592752
592763
  const auth = await getAuthenticatedClient(fsAdapter);
592753
592764
  const calendarApi = import_googleapis2.google.calendar({ version: "v3", auth });
592754
592765
  const api2 = createGoogleCalendarApi(calendarApi);
592755
- const calendarId = showOpts.calendar ?? (globalOpts.calendar.length > 0 ? globalOpts.calendar[0] : undefined);
592766
+ const calendarId = showOpts.calendar;
592756
592767
  let cal;
592757
592768
  if (calendarId) {
592758
592769
  const found = config2.calendars.find((c) => c.id === calendarId);
592759
592770
  cal = found ? { id: found.id, name: found.name } : { id: calendarId, name: calendarId };
592760
592771
  } else {
592761
592772
  const calendars = selectCalendars(undefined, config2);
592762
- const resolved = await resolveEventCalendar(api2, showCmd.args[0], calendars);
592773
+ const resolved = await resolveEventCalendar(api2, eventId, calendars);
592763
592774
  cal = resolved;
592764
592775
  }
592765
592776
  const timezone = resolveTimezone(globalOpts.timezone, config2.timezone);
592766
592777
  const result = await handleShow({
592767
592778
  api: api2,
592768
- eventId: showCmd.args[0],
592779
+ eventId,
592769
592780
  calendarId: cal.id,
592770
592781
  calendarName: cal.name,
592771
592782
  format: globalOpts.format,
592783
+ quiet: globalOpts.quiet,
592772
592784
  timezone,
592773
592785
  write: (msg) => process.stdout.write(msg + `
592774
592786
  `)
@@ -592789,8 +592801,8 @@ ${url}`);
592789
592801
  const calendarApi = import_googleapis2.google.calendar({ version: "v3", auth });
592790
592802
  const api2 = createGoogleCalendarApi(calendarApi);
592791
592803
  let resolvedCalendarId;
592792
- if (deleteOpts.calendar || globalOpts.calendar.length > 0) {
592793
- const calendars = selectCalendars(deleteOpts.calendar ? [deleteOpts.calendar] : globalOpts.calendar, config2);
592804
+ if (deleteOpts.calendar) {
592805
+ const calendars = selectCalendars([deleteOpts.calendar], config2);
592794
592806
  resolvedCalendarId = calendars[0]?.id ?? "primary";
592795
592807
  } else {
592796
592808
  const calendars = selectCalendars(undefined, config2);
@@ -592834,10 +592846,12 @@ ${url}`);
592834
592846
  description: addOpts.description,
592835
592847
  busy: addOpts.busy,
592836
592848
  free: addOpts.free,
592849
+ dryRun: addOpts.dryRun,
592850
+ quiet: globalOpts.quiet,
592837
592851
  format: globalOpts.format
592838
592852
  };
592839
- if (globalOpts.calendar?.[0])
592840
- handleOpts.calendar = globalOpts.calendar[0];
592853
+ if (addOpts.calendar)
592854
+ handleOpts.calendar = addOpts.calendar;
592841
592855
  if (globalOpts.timezone)
592842
592856
  handleOpts.timezone = globalOpts.timezone;
592843
592857
  const result = await handleAdd(handleOpts, deps);
@@ -592910,8 +592924,8 @@ ${authUrl}`);
592910
592924
  const timezone = resolveTimezone(globalOpts.timezone, config2.timezone);
592911
592925
  const updateOpsCalendar = updateOpts.calendar;
592912
592926
  let cal;
592913
- if (updateOpsCalendar || globalOpts.calendar.length > 0) {
592914
- const calendars = selectCalendars(updateOpsCalendar ? [updateOpsCalendar] : globalOpts.calendar, config2);
592927
+ if (updateOpsCalendar) {
592928
+ const calendars = selectCalendars([updateOpsCalendar], config2);
592915
592929
  cal = calendars[0];
592916
592930
  } else {
592917
592931
  const calendars = selectCalendars(undefined, config2);
@@ -592924,6 +592938,7 @@ ${authUrl}`);
592924
592938
  calendarId: cal.id,
592925
592939
  calendarName: cal.name,
592926
592940
  format: globalOpts.format,
592941
+ quiet: globalOpts.quiet,
592927
592942
  timezone,
592928
592943
  write: (msg) => process.stdout.write(msg + `
592929
592944
  `),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ncukondo/gcal-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"