Skip to content

refactor: add root command options helper#66

Closed
abhijeetnardele24-hash wants to merge 1 commit intolinearis-oss:mainfrom
abhijeetnardele24-hash:refactor/root-command-options-helper
Closed

refactor: add root command options helper#66
abhijeetnardele24-hash wants to merge 1 commit intolinearis-oss:mainfrom
abhijeetnardele24-hash:refactor/root-command-options-helper

Conversation

@abhijeetnardele24-hash
Copy link
Copy Markdown

Summary

  • add a getRootOpts() helper that walks up to the root Commander command
  • replace fragile command.parent!.parent!.opts() access across the command layer
  • add a focused unit test for nested and root command resolution

Validation

px vitest run tests/unit/context.test.ts

px tsc --noEmit

Note

pm run build compiles successfully on this machine until the repo's POSIX-only chmod step, which is unavailable in Windows PowerShell

Copilot AI review requested due to automatic review settings April 7, 2026 14:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the CLI command layer to safely access root (global) Commander options by introducing a getRootOpts() helper, replacing brittle command.parent!.parent!.opts() chains, and adding a unit test to validate root option resolution for nested commands.

Changes:

  • Added getRootOpts(command) utility to traverse the Commander parent chain and return root CommandOptions.
  • Replaced command.parent!.parent!.opts() usages across multiple commands with getRootOpts(command) (and hoisted into a local rootOpts where used multiple times).
  • Added unit tests covering nested-command and root-command behavior for getRootOpts().

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/unit/context.test.ts Adds focused unit tests for resolving root options from nested and root commands.
src/utils/context.ts Introduces getRootOpts() helper to retrieve root Commander options.
src/commands/users.ts Uses getRootOpts(command) when creating LinearService.
src/commands/teams.ts Uses getRootOpts(command) when creating LinearService.
src/commands/projects.ts Uses getRootOpts(command) when creating LinearService.
src/commands/project-milestones.ts Hoists rootOpts and reuses it for GraphQL + Linear services.
src/commands/labels.ts Uses getRootOpts(command) when creating LinearService.
src/commands/issues.ts Hoists rootOpts per action and reuses it for GraphQL + Linear services.
src/commands/embeds.ts Uses getRootOpts(command) when retrieving API token.
src/commands/documents.ts Uses getRootOpts(command) to build services consistently across actions.
src/commands/cycles.ts Uses getRootOpts(command) when creating LinearService.
src/commands/comments.ts Uses getRootOpts(command) when creating LinearService.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@iamfj
Copy link
Copy Markdown
Member

iamfj commented Apr 8, 2026

Will be fixed in #89

@iamfj iamfj closed this Apr 8, 2026
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.

3 participants