refactor: add root command options helper#66
Closed
abhijeetnardele24-hash wants to merge 1 commit intolinearis-oss:mainfrom
Closed
refactor: add root command options helper#66abhijeetnardele24-hash wants to merge 1 commit intolinearis-oss:mainfrom
abhijeetnardele24-hash wants to merge 1 commit intolinearis-oss:mainfrom
Conversation
There was a problem hiding this comment.
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 rootCommandOptions. - Replaced
command.parent!.parent!.opts()usages across multiple commands withgetRootOpts(command)(and hoisted into a localrootOptswhere 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.
Member
|
Will be fixed in #89 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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