feat!: support positional value resolving with schema - #83
Merged
Conversation
commit: |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for resolving positional argument values via an updated schema, simplifying value resolution and validation.
- Updated and renamed schema interfaces from ArgOptionSchema/ArgOptions to ArgSchema/Args.
- Added logic for handling skipPositional and positional tokens in resolveArgs.
- Updated API interfaces, tests, and export types to reflect the new argument concept.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/resolver.ts | Renamed interfaces and implemented positional argument resolution logic including skipPositional handling. |
| src/resolver.test-d.ts | Updated type tests to reflect new ArgSchema definitions. |
| src/parse.ts | Adjusted parse function parameters and types to replace options with args. |
| src/parse.test.ts | Updated tests to use new args structure and validate parse functionality. |
| src/index.ts | Updated exports to match new naming and API interface changes. |
|
|
||
| if (schema.type === 'positional') { | ||
| if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) { | ||
| while (positionalsCount <= getPositionalSkipIndex()) { |
There was a problem hiding this comment.
The loop condition using '<=' may cause an off-by-one error when skipping positional tokens. Consider changing the condition to '<' to ensure the correct positional token is selected.
Suggested change
| while (positionalsCount <= getPositionalSkipIndex()) { | |
| while (positionalsCount < getPositionalSkipIndex()) { |
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.
Description
This PR will support resolving values from a schema that defines positional arguments.
This eliminates the need to resolve or validate values yourself from the positionals returned by
resolveArgs.Linked Issues
related issue: kazupon/gunshi#108
Additional context
This PR will result in changes to type definitions and API interfaces. That means it is a breaking change.