Add requiredIfNonInteractive flag factory and apply to app init --template#7716
Draft
nickwesselman wants to merge 1 commit into
Draft
Add requiredIfNonInteractive flag factory and apply to app init --template#7716nickwesselman wants to merge 1 commit into
requiredIfNonInteractive flag factory and apply to app init --template#7716nickwesselman wants to merge 1 commit into
Conversation
…mplate` Introduce a `requiredIfNonInteractive` flag factory in cli-kit that marks a flag as required when running in a non-interactive terminal (CI, piped input), while keeping it optional in interactive sessions where the command can prompt. - The factory tags the flag with a custom `requiredIfNonInteractive` property and prepends "(required if non-interactive)" to its description, mirroring oclif's "(required)" rendering. - BaseCommand.parse() auto-collects flags carrying the marker from the live command class and routes them through the existing failMissingNonTTYFlags helper, so every command gets the behavior without a hardcoded list. - Apply it to `app init --template` as the first usage. The custom property is read from the live command class at parse time, since it is stripped from the cached oclif manifest. The help annotation lives in `description` (a cached field) so it survives manifest generation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
WHY are these changes introduced?
Related to https://github.com/shop/issues-develop/issues/22928
Some flags shouldn't be strictly
required(the command can prompt for them in an interactive session), but they must be supplied when the CLI runs non-interactively (CI, or piped input). TodayBaseCommandalready hasfailMissingNonTTYFlags(), but each command has to pass a hardcoded list of flag names, and there's no way to surface the requirement in--help.WHAT is this pull request doing?
Introduces a
requiredIfNonInteractiveflag factory in cli-kit and wires it into the base command, and applies it toapp init --templateas the first usage.Design note
The custom
requiredIfNonInteractiveproperty is read from the live command class at parse time, because it is stripped from the cached oclif manifest (cacheFlagsonly copies an allowlist of known properties). The help annotation instead lives indescription— a cached field — so it survives manifest generation. This is why the manifest diff shows the new description but not the custom property.How to test your changes?
In a non-interactive shell (no TTY / CI):
shopify app init --helpshows:In an interactive terminal,
app initstill prompts for the template as before.Measuring impact
Checklist
🤖 Generated with Claude Code