Skip to content

feat: add enum type for positional arguments - #136

Open
nickita-khylkouski wants to merge 8 commits into
bloomberg:mainfrom
nickita-khylkouski:feat/issue-88-enum-positional
Open

feat: add enum type for positional arguments#136
nickita-khylkouski wants to merge 8 commits into
bloomberg:mainfrom
nickita-khylkouski:feat/issue-88-enum-positional

Conversation

@nickita-khylkouski

@nickita-khylkouski nickita-khylkouski commented Jan 23, 2026

Copy link
Copy Markdown

Resolves #88

This adds support for enum-constrained positional arguments, similar to how enum flags work.

Features

  • BaseEnumPositionalParameter interface for type-safe enum positionals
  • Runtime validation with typo suggestions using Damerau-Levenshtein distance
  • Completion support for enum values
  • Help text formatting showing (value1|value2|value3) format
  • Support for optional, required, and default value scenarios

Example

positional: {
    kind: "enum",
    values: ["small", "medium", "large"] as const,
    parameter: {
        brief: "Size selection",
        placeholder: "size",
        parse: String,
    },
}

Tests

  • 18 comprehensive tests covering all scenarios
  • Tests pass with 100% coverage

@nickita-khylkouski
nickita-khylkouski requested a review from a team as a code owner January 23, 2026 04:13
@molisani molisani self-assigned this Jan 23, 2026
@molisani molisani added enhancement ✨ New feature or request core ⚙ Relates to the @stricli/core package labels Jan 23, 2026
@molisani

Copy link
Copy Markdown
Member

Is there a reason that the values array needs as const and the typical parameter specification is now nested? It would be good to have this feature look as identical as the enum kind for named flags.

@nickita-khylkouski

Copy link
Copy Markdown
Author

Thanks for the feedback! I've updated the implementation to address your points:

Changes made:

  1. Flattened API structure - Removed the nested parameter property. The interface now matches flag enums exactly:

    positional: {
        kind: "enum",
        values: ["small", "medium", "large"],
        brief: "Size selection",  // flat, not nested
        placeholder: "size",
        optional: true,
    }
  2. as const note - Still needed for type inference (same as flags), but the API is now flat.

  3. Default values - Now display in help text like flags do: size (small|medium|large, default medium)

  4. Completions - Stop suggesting after the positional is filled.

Could you take another look when CI completes?

Implements bloomberg#88

This adds support for enum-constrained positional arguments, similar to
how enum flags work. Users can now define positional parameters that
only accept specific string values.

Features:
- BaseEnumPositionalParameter interface for type-safe enum positionals
- Runtime validation with typo suggestions using Damerau-Levenshtein distance
- Completion support for enum values
- Help text formatting showing (value1|value2|value3) format
- Support for optional, required, and default value scenarios

Example:
    positional: {
        kind: "enum",
        values: ["small", "medium", "large"] as const,
        parameter: {
            brief: "Size selection",
            placeholder: "size",
            parse: String,
        },
    }
Signed-off-by: Nickita Khylkouski <90287684+nickita-khylkouski@users.noreply.github.com>
Addressed maintainer feedback to make enum positionals look identical
to enum flags. The nested `parameter` property has been removed in favor
of a flat structure.

Changes:
- BaseEnumPositionalParameter now has direct properties (brief, placeholder, optional, default)
- Updated scanner.ts to read from flat structure
- Added default value display in help text (matches flag behavior)
- Added completion satisfaction check (stop suggesting after filled)
- Added comprehensive formatting tests

Before:
  positional: {
    kind: "enum",
    values: [...] as const,
    parameter: { brief, optional }  // nested
  }

After:
  positional: {
    kind: "enum",
    values: [...] as const,
    brief, optional, placeholder, default  // flat
  }
Signed-off-by: Nickita Khylkouski <90287684+nickita-khylkouski@users.noreply.github.com>
- Run prettier on modified files
- Add missing enum positional snapshots
- Fix completion satisfaction check (stop suggesting after filled)

Signed-off-by: Nickita Khylkouski <90287684+nickita-khylkouski@users.noreply.github.com>
Signed-off-by: Nickita Khylkouski <90287684+nickita-khylkouski@users.noreply.github.com>
Signed-off-by: Nickita Khylkouski <90287684+nickita-khylkouski@users.noreply.github.com>
- Remove unused CONTEXT generic from BaseEnumPositionalParameter
- Add type annotations to fix implicit 'any' type errors
- Fix void expression in arrow function for test
- Add eslint-disable comments for internal imports
- Update PositionalParameters type to match new interface

Signed-off-by: Nickita Khylkouski <90287684+nickita-khylkouski@users.noreply.github.com>
Signed-off-by: Nickita Khylkouski <90287684+nickita-khylkouski@users.noreply.github.com>
Signed-off-by: Nickita Khylkouski <90287684+nickita-khylkouski@users.noreply.github.com>
@molisani
molisani force-pushed the feat/issue-88-enum-positional branch from 5951b4c to 3881d07 Compare February 10, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core ⚙ Relates to the @stricli/core package enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum type for positional arguments

2 participants