Skip to content

feat!: support positional value resolving with schema - #83

Merged
kazupon merged 3 commits into
mainfrom
feat/positional-resolving
May 4, 2025
Merged

feat!: support positional value resolving with schema#83
kazupon merged 3 commits into
mainfrom
feat/positional-resolving

Conversation

@kazupon

@kazupon kazupon commented May 4, 2025

Copy link
Copy Markdown
Owner

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.

@kazupon kazupon added breaking Includes backwards-incompatible fixes feature Includes new features labels May 4, 2025
@pkg-pr-new

pkg-pr-new Bot commented May 4, 2025

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/kazupon/args-tokens@83

commit: dc01829

@kazupon
kazupon requested a review from Copilot May 4, 2025 17:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment thread src/resolver.ts

if (schema.type === 'positional') {
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) {
while (positionalsCount <= getPositionalSkipIndex()) {

Copilot AI May 4, 2025

Copy link

Choose a reason for hiding this comment

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

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()) {

Copilot uses AI. Check for mistakes.
@kazupon
kazupon merged commit 6022239 into main May 4, 2025
@kazupon
kazupon deleted the feat/positional-resolving branch May 4, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Includes backwards-incompatible fixes feature Includes new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants