generate feature
Create a feature folder, optionally with screens and a service.
Creates a feature folder under Features/ and, if requested, scaffolds screens and a service inside it.
Synopsis
Section titled “Synopsis”swiftspawn generate feature <Name> [--screens <names>] [--service <name>] [--with-tests] [--dry-run] [--force] [--quiet] [--verbose]Description
Section titled “Description”A feature is a folder grouping related screens and feature-local models. Plain generate feature Movies just creates the folder structure. With --screens or --service, the same call also scaffolds those pieces and wires them up.
This is a convenience wrapper around generate screen and generate service; you can always run them separately.
Examples
Section titled “Examples”swiftspawn generate feature Moviesswiftspawn generate feature Movies --screens MovieList,MovieDetailswiftspawn generate feature Movies --service Movie --screens MovieList --with-testsGenerated files
Section titled “Generated files”Plain feature:
Features/<Name>/Features/<Name>/Models/With --screens MovieList,MovieDetail:
Features/Movies/MovieList/MovieListView.swiftFeatures/Movies/MovieList/MovieListViewModel.swiftFeatures/Movies/MovieDetail/MovieDetailView.swiftFeatures/Movies/MovieDetail/MovieDetailViewModel.swiftWith --service Movie:
Services/MovieService.swiftServices/MovieServiceImpl.swiftServices/MockMovieService.swift--with-tests adds matching *Tests.swift files under Tests/<App>Tests/.
Side effects
Section titled “Side effects”- Adds one route case per screen to
Route.swift(between markers). - Wires each screen into
RootView.swift’s navigation switch (between markers). - Registers the service in
DIContainer.swift(between markers) if--serviceis passed.
See Markers for how marker-region edits work.
Options
Section titled “Options”| Flag | Description |
|---|---|
--screens <names> | Comma-separated screen names (e.g. MovieList,MovieDetail). |
--service <name> | Service name to create alongside the feature. |
--with-tests | Also generate matching test files. |
--dry-run | Preview without writing. |
--force | Overwrite existing files. |
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 2 | Invalid name. |
| 5 | Not in a swiftspawn project. |
| 7 | Route.swift is missing the markers. |