Skip to content

[TW-4826] feat(scheduler): add extended flags, file input, and validation to configurations#47

Merged
qasim-nylas merged 1 commit intomainfrom
feature/TW-4826-scheduler-config-flags
Apr 11, 2026
Merged

[TW-4826] feat(scheduler): add extended flags, file input, and validation to configurations#47
qasim-nylas merged 1 commit intomainfrom
feature/TW-4826-scheduler-config-flags

Conversation

@qasim-nylas
Copy link
Copy Markdown
Collaborator

@qasim-nylas qasim-nylas commented Apr 11, 2026

Summary

Enhances nylas scheduler configurations create and update commands with full Nylas Scheduler API coverage, JSON file input support, and fail-fast validation.

  • Add 16 new flags covering availability settings, event booking options, scheduler settings, and --file JSON input with flag-override support
  • Extract helpers to configurations_helpers.go for flag registration, enum validation, request building, and display formatting
  • Move validation before auth so users get immediate feedback on missing/invalid fields without needing API credentials

Details

New Flags

Category Flags
Availability --interval, --round-to, --availability-method, --buffer-before, --buffer-after
Event Booking --timezone, --booking-type, --conferencing-provider, --disable-emails, --reminder-minutes
Scheduler Settings --min-booking-notice, --min-cancellation-notice, --confirmation-method, --available-days-in-future, --cancellation-policy
File Input --file (JSON config file; flags override file values)

File Input Support

Users can now create/update configurations from a JSON file matching the API request structure. When both --file and flags are provided, flags take precedence over file values. This enables workflows like:

# Export → edit → recreate
nylas scheduler configs show abc123 --json > meeting.json
# Edit meeting.json...
nylas scheduler configs create --file meeting.json

# File as base, override specific values
nylas scheduler configs create --file config.json --duration 60

Refactoring

  • configurations_helpers.go (new) — Extracted configFlags struct, registerConfigFlags(), validateConfigFlags(), buildCreateRequest(), buildUpdateRequest(), and formatConfigDetails() from inline code in configurations.go
  • Fail-fast validationvalidateConfigFlags() checks enum values and validateCreateRequest()/validateUpdateRequest() check required fields before WithClient() is called, so errors like missing --name or invalid --booking-type surface without requiring auth
  • Removed MarkFlagRequired — Replaced with custom validation to support the --file input path where fields come from the file rather than flags

Files Changed

File Change
internal/cli/scheduler/configurations.go Refactored create/update commands to use extracted helpers and new flags
internal/cli/scheduler/configurations_helpers.go New — Flag registration, validation, request building, display formatting
internal/cli/scheduler/configurations_helpers_test.go New — Unit tests for all helper functions (validation, request building, file input, display)
internal/cli/scheduler/configurations_command_test.go New — Command-level tests verifying validation errors occur before auth errors
internal/cli/scheduler/scheduler_test.go Expanded flag existence tests for new availability, event booking, scheduler, and file flags
docs/commands/scheduler.md Updated with flags table, examples, and file input documentation

Test Plan

  • Unit tests for enum validation (validateConfigFlags) — valid and invalid values for all enum flags
  • Unit tests for buildCreateRequest — file-only, flags-only, flags-override-file scenarios
  • Unit tests for buildUpdateRequest — file-only, flags-only, flags-override-file scenarios
  • Unit tests for validateCreateRequest / validateUpdateRequest — missing fields, empty update detection
  • Unit tests for formatConfigDetails — full config and minimal config output
  • Command-level tests confirming validation errors fire before auth errors (no API key needed)
  • Flag existence tests for all 16 new flags on both create and update commands
  • Manual: nylas scheduler configs create --name "Test" --title "Test" --participants user@example.com --duration 30
  • Manual: nylas scheduler configs create --file config.json
  • Manual: nylas scheduler configs update <id> --buffer-before 5 --conferencing-provider "Google Meet"

JIRA: TW-4826

…tion to configurations

Add 16 new flags to scheduler configurations create/update commands covering
availability, event booking, scheduler settings, and JSON file input with
flag-override support. Extract helpers for validation and request building,
and move validation before auth for fail-fast error handling.
@qasim-nylas qasim-nylas requested a review from AaronDDM April 11, 2026 11:33
Copy link
Copy Markdown
Collaborator

@AaronDDM AaronDDM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@qasim-nylas qasim-nylas merged commit dbf4419 into main Apr 11, 2026
6 checks passed
@qasim-nylas qasim-nylas deleted the feature/TW-4826-scheduler-config-flags branch April 11, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants