Problem
seamless init --bogus in a non-empty directory asks the destructive overwrite question
before it ever discovers the flag is unknown.
The order in src/commands/init.ts is:
scaffold() reads the directory and, when it is not empty, calls
chooseExistingDirectoryAction() (src/prompts/initMode.ts),
which prompts "Scaffold a project here anyway? Starter files overwrite anything with the
same name."
- Only after that does
scaffoldLocal() / scaffoldManaged() call
resolveTemplateAliases(), which is what throws Unknown option "--bogus".
So a typo, or the documented "run an unknown flag to see the available examples" hint, both
route a developer through an overwrite prompt on the way to an error. The default is No and
it requires explicit confirmation, which is what keeps this from being a data-loss bug, but
the common scripted pattern of piping y at the first prompt turns it into one.
PR #148 fixed the worst instance of this (--help / -h are now handled ahead of every
command's own parsing), but any other unrecognized flag still takes the same path.
Change
- Resolve and validate template flags in
runCLI() before scaffold() touches the
filesystem, so an unknown or conflicting flag exits non-zero with the available flags
listed and nothing is prompted.
- Keep the existing error text from
resolveTemplateAliases(); only the timing moves.
- Drop the "Run an unknown flag to see the available examples" line from the
init help body
in src/commands/helpTopics.ts. Discovery belongs in
seamless templates list (separate issue), not in an error path.
Acceptance
seamless init --bogus in a directory full of files errors immediately, prompts nothing,
and exits non-zero.
- Conflicting flags (two web templates) behave the same way.
- A valid flag still reaches the existing-directory prompt exactly as it does today.
- Unit test covering "unknown flag in a non-empty directory never calls the prompt".
Problem
seamless init --bogusin a non-empty directory asks the destructive overwrite questionbefore it ever discovers the flag is unknown.
The order in src/commands/init.ts is:
scaffold()reads the directory and, when it is not empty, callschooseExistingDirectoryAction()(src/prompts/initMode.ts),which prompts "Scaffold a project here anyway? Starter files overwrite anything with the
same name."
scaffoldLocal()/scaffoldManaged()callresolveTemplateAliases(), which is what throwsUnknown option "--bogus".So a typo, or the documented "run an unknown flag to see the available examples" hint, both
route a developer through an overwrite prompt on the way to an error. The default is
Noandit requires explicit confirmation, which is what keeps this from being a data-loss bug, but
the common scripted pattern of piping
yat the first prompt turns it into one.PR #148 fixed the worst instance of this (
--help/-hare now handled ahead of everycommand's own parsing), but any other unrecognized flag still takes the same path.
Change
runCLI()beforescaffold()touches thefilesystem, so an unknown or conflicting flag exits non-zero with the available flags
listed and nothing is prompted.
resolveTemplateAliases(); only the timing moves.inithelp bodyin src/commands/helpTopics.ts. Discovery belongs in
seamless templates list(separate issue), not in an error path.Acceptance
seamless init --bogusin a directory full of files errors immediately, prompts nothing,and exits non-zero.