Skip to content

type-architecture: add domain value parsers for CLI concepts such as label mode and priority #205

@iamfj

Description

@iamfj

What problem does this solve?

Several validated CLI concepts remain primitive strings or numbers after validation. For example, labelMode is validated against add/overwrite but remains typed as string. Priority and estimate are parsed as numbers but their validated meaning is not carried by the type.

Proposed solution

Introduce parser functions that return narrowed domain types.

Examples:

export type LabelMode = "add" | "overwrite";

export function parseLabelMode(value: string | undefined): LabelMode | undefined {
  if (value === undefined) return undefined;
  if (value === "add" || value === "overwrite") return value;
  throw invalidParameterError("--label-mode", "must be either 'add' or 'overwrite'");
}

export type IssuePriority = 0 | 1 | 2 | 3 | 4;

Acceptance criteria:

  • labelMode is narrowed to "add" | "overwrite" after parsing.
  • Priority parsing returns a constrained type or documented validated number.
  • Commands avoid repeated raw string checks after parsing.
  • Behavior remains unchanged.

Alternatives considered

Keep primitive string/number types after validation. This is simple but loses useful type information immediately after parsing.

Primary use case

LLM agent integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerspriority:P3Low-priority backlog item or nice-to-have improvementqa:smell

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions