Skip to content

feat: add command-level constraint framework @W-20534184@#1580

Open
jfeingold35 wants to merge 10 commits intomainfrom
d/W-20534184
Open

feat: add command-level constraint framework @W-20534184@#1580
jfeingold35 wants to merge 10 commits intomainfrom
d/W-20534184

Conversation

@jfeingold35
Copy link
Copy Markdown
Contributor

This PR is the implementation of a syntax for command-level constraints. It will close #1507 when it is finally merged.

@W-20534184@

@git2gus
Copy link
Copy Markdown

git2gus Bot commented Apr 17, 2026

Git2Gus App is installed but the .git2gus/config.json doesn't have right values. You should add the required configuration.

@jfeingold35 jfeingold35 force-pushed the d/W-20534184 branch 4 times, most recently from 11fa9fd to 3f7bad4 Compare April 22, 2026 23:19
@jfeingold35 jfeingold35 marked this pull request as ready for review April 23, 2026 14:35
Comment thread src/constraints.ts
// istanbul ignore if - should be unreachable
if (this.condition) {
throw new Error('FILLER: DUPLICATE CONDITION')
}
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.

do this need to throw a message instead?
example: throw new Error(Misconfigured constraint: duplicate condition set on ${this.getName()})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In theory this should be unreachable, but yeah, can't hurt to have a specific message here.

Comment thread src/command.ts Outdated
const opts = {
context: this,
...options,
constraints: options.constraints,
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.

add constraints here is redundant of ...options or is this intentional to override?

in ...options:

export type Input<TFlags extends FlagOutput, BFlags extends FlagOutput, AFlags extends ArgOutput> = {
  flags?: FlagInput<TFlags>
  baseFlags?: FlagInput<BFlags>
  constraints?: Constraint[] | undefined
  enableJsonFlag?: true | false
  args?: ArgInput<AFlags>
  strict?: boolean | undefined
  context?: ParserContext
  '--'?: boolean
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, good catch. I'll remove the constraints declaration here. It serves no purpose.

Comment thread src/constraints.ts Outdated
* Declare a set of flags to be evaluated as one instead of separately.
*
* @example
* flag('foo').is.dependentOn(combinationOf('bar', 'baz))
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.

mini typo 'baz'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New flag Constraints API Proposal

2 participants