feat(compositions): add interactive mode to compositions commands#252
Open
ben-kalmus wants to merge 3 commits into
Open
feat(compositions): add interactive mode to compositions commands#252ben-kalmus wants to merge 3 commits into
ben-kalmus wants to merge 3 commits into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 437 |
| Duplication | 211 |
TIP This summary will be updated as you push new changes.
4f6cadc to
25d7c61
Compare
c17e3a6 to
9a22ae5
Compare
25d7c61 to
09a8a59
Compare
9a22ae5 to
d0c4a17
Compare
cc9c665 to
1c99234
Compare
LorrisSaintGenez
approved these changes
Jul 6, 2026
LorrisSaintGenez
left a comment
Contributor
There was a problem hiding this comment.
Feel free to merge into #249 once you fix them
Inject a Prompter through cmdutil.Factory (defaulted to a survey-backed prompter in factory.New) and add an --interactive/-i flag to the compositions commands that build a request body: - compositions upsert -> Composition - compositions rules upsert -> CompositionRule - compositions search -> search RequestBody (query optional under -i) Each builds the body with the interactive engine instead of requiring JSON; --file and --interactive are mutually exclusive and interactive requires a TTY. Adds a group-level integration test plus per-command interactive tests.
- search: reject a positional query or --hits-per-page/--page/--filters when --interactive is set, instead of silently ignoring them - drop the redundant nil-Prompter fallback in upsert, rules upsert, search, and sorting-strategy (factory.New always sets it; Builder errors on nil anyway)
1c99234 to
a8ec51f
Compare
78d6c9b to
a221553
Compare
Contributor
Author
@LorrisSaintGenez I thought i'd merge in the interactive builder into main first, then rebase this branch on main and merge that after. Or do you prefer merging one squashed commit with both interactive + compositions ? |
LorrisSaintGenez
approved these changes
Jul 7, 2026
Contributor
|
@ben-kalmus You can do that too yes! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds an
--interactive/-iflag to thecompositionscommands that build a request body, so users can construct the body through prompts instead of hand-writing JSON.Covered commands:
compositions upsert(Composition),compositions rules upsert(CompositionRule),compositions search(search RequestBody).Stacked on the interactive engine PR feat(interactive): add reflection-driven interactive prompt engine #249 (merge that first).
Demos
Upsert
Upsert Rule
Search
Stacked PRs
feat(interactive): add reflection-driven interactive prompt engine #249
feat(compositions): add interactive mode to compositions commands #252 <- this PR
Usage
Design notes
The
Prompteris provided bycmdutil.Factory(defaulted to a survey-backed prompter infactory.New), so each command receives it as a dependency and tests inject a fake. No test-only seam on the command signatures.For the write commands,
--fileand--interactiveare mutually exclusive and exactly one is required. Forsearch,--interactivemakes the positional<query>optional (the request is built from prompts).--interactivealways requires a TTY and errors otherwise.Identifiers from positional args are pre-populated (composition objectID, rule objectID), so they are not prompted.
Non-interactive (
--file/ positional query) behavior is unchanged.Changes
pkg/cmdutil/factory.go: add aPrompterfield toFactory.pkg/cmd/factory/default.go: defaultPrompterto a survey-backed prompter built from the IO streams.pkg/cmd/compositions/upsert/upsert.go:--interactive/-i, flag validation, interactive build path.pkg/cmd/compositions/rules/upsert/upsert.go: same for composition rules (CompositionRule).pkg/cmd/compositions/search/search.go:--interactive/-ibuilding the searchRequestBody; query argument made optional under-i(RangeArgs(1,2)).pkg/cmd/compositions/compositions_test.go).Tests
JSONEqat the command-group level), rules upsert, and search, all driven by a scripted prompter on the factory.--file+--interactiveconflict, and--interactivewithout a TTY.--file/ positional-query behavior covered by the unchanged tests.