refactor(flags): centralize flag parsing #343
Merged
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.
Closes #318
Applied changes based on Issue #318.
I’ve centralized all of the ad-hoc flag handling into a single utility (
parseFlags
) and refactoredprocessEvent
to use it in both the direct-prompt and comment-parsing paths.Changes in brief:
• Added
src/utils/flags.ts
– parseFlags(input, flagNames[]) splits once, builds a flags map, and returns the cleaned-up remainder.
• Updated
src/github/event.ts
– Imported
parseFlags
and removed all repeated.split
/.replace
flag logic.– In the direct-prompt branch, we now parse
--fix-build
and--fetch
viaparseFlags
.– In the
/codex
comment branch, we parse all five flags (full-history
,create-issues
,no-pr
,fix-build
,fetch
) in one go.This eliminates duplicated splitting/replacement, makes it easy to add or change flags in one place, and keeps behavior identical to before. All existing tests for
processEvent
should continue to pass unchanged.