ftkit new
Add a new component to an existing Fountain service.
Usage
ftkit newThe command is also available under the alias n. It takes no arguments — running it starts an interactive prompt that walks you through choosing one or more components to generate (powered by promptui).
What it does
new first reads the current module's environment data (it runs go list -m in the project root), then presents a multi-select menu titled "Choose the component(s) to add to the service". Based on your selection it generates the corresponding files and wires them into the existing service — updating server/server.go, biz/biz.go, and biz/dal/dao/managers.go as needed (a backup of each edited file is taken first).
Run new from the root of a service that was created with ftkit init.
Components it can generate
The interactive menu offers these component types (see cmd/new.go / cmd/new_func.go):
| Component | What it generates |
|---|---|
controller | A new controller domain under biz/core/<name>/, registered via a blank import in biz/biz.go. |
handler | A handler package under server/<name>/, with the handler field and constructor wired into the server struct's Initialize(). |
dao | A DAO/cache under biz/dal/dao/<storage>_dao/, registered in managers.go and installed in server.go. Optionally generates the matching model. |
pkg | A reusable package skeleton under pkg/<name>/. |
client | A client library package (<service>_client/) for calling the service. |
server | A protocol server added to the server struct, wired into Initialize(), Serving() and Destroy(). |
Server protocols
When you choose server, you pick one of the supported protocols:
grpchttptcpudp
DAO storage backends
When you choose dao, you pick a storage backend. The supported backends (from createNewComponentDAO) are:
| Storage | Generated artifact |
|---|---|
redis | A *Cache in redis_dao/, installed via InstallRedisDAOManager. |
mysql | A *DAO in mysql_dao/, installed via InstallSQLDAOManager. |
postgres / postgresql | A *DAO in postgres_dao/, installed via InstallSQLDAOManager. |
mongo / mongodb | A *DAO in mongo_dao/, installed via InstallMongoDAOManager. |
cql / scylla / cassandra | A *STO in cassandra_dao/, installed via InstallCQLDAOManager. |
elastic | A *STO in elastic_dao/, installed via InstallElasticDAOManager. |
For a DAO you are also asked whether to generate the DAO from a model — if you choose yes, a model file is created (or an existing one is reused) under biz/dal/models/ and its db:"..." tags are used to populate the generated SQL DAO.
TIP
new is fully interactive — there are no command-line flags. All choices (component type, storage, names) are entered through the prompts.
Known limitations
note.txt in the ftkit repository tracks several planned-but-not-yet-implemented refinements for new — for example a new mvc flow that would generate models → handler → controller → dao in one pass, an option to create all missing DAOs for /models, and import-path fixes for multi-word handler names. These are not available yet and are intentionally not documented here as working features.