Finch CLI
The Finch CLI is a command-line tool for creating projects, running the dev server, building, running tests, and managing database migrations. It wraps common Dart commands and adds Finch-specific tasks.
Install
dart pub global activate finch
Commands
Run finch -h to see all available commands:
finch -h
✔ templates
Show the list of available templates
✔ create
Make new project
-p, --path Path of the project
-n, --name Name of project
-d, --docker Use docker
-t, --template Project template [simple, example,...]
✔ get
Get packages of project, (dart pub get)
✔ runner
Build runner of project, (dart pub run build_runner build)
✔ run
Run project, (dart run)
-p, --path Path of app file
-a, --args Arguments for app file
✔ serve
Serve project with file watcher
-p, --path Path of app file
-a, --args Arguments for app file
✔ build
Build Project (dart compile exe)
-c, --cli Build for cli
-a, --appPath Path of app file
-l, --langPath Languages path
-p, --publicPath Public path
-w, --widgetPath Widgets path
-e, --envPath Envitoment file (.env) path
-o, --output Output path
-t, --type Type of build (zip, exe)
✔ migrate
Migrate project to new version of Finch
-c, --create Create new project and move files
-n, --name Name of migration file (only for create option)
-s, --sqlite Migrate SQLite files
✔ test
Unit test of project, (dart test)
-r, --reporter Set how to print test results
✔ make:controller
Make new controller
-n, --name Name of controller
-p, --path Path of controller (default: ./lib/controllers/)
✔ make:service
Make new service
-n, --name Name of service
-p, --path Path of service (default: ./lib/services/)
✔ make:middleware
Make new middleware
-n, --name Name of middleware
-p, --path Path of middleware (default: ./lib/middleware/)
-h, --help Show the help
-v, --version Finch Version
-u, --update Update Finch
Common Usage Examples
Create a new project with the example template
finch create -n my_app -t example
Run the dev server with file watcher
The serve command watches widget and language files and hot-reloads them without restarting the server:
finch serve
Or specify the entry point:
finch serve -p lib/serve.dart
Build a production binary
finch build -a lib/app.dart -o ./build/app
Run database migrations
# Apply all pending MySQL migrations
finch migrate --init
# Create a new MySQL migration file
finch migrate --create --name add_users_table
# Apply SQLite migrations
finch migrate --init --sqlite
The
migratecommand delegates to the running app's built-in migration system. See Database Migration for details.