The Dext.Hosting.CLI (also referred to as dext.exe or DextTool.exe) is the command-line interface for the Dext Framework. It provides essential utilities for project management, testing, and database migrations.
📝 Note: The CLI tool is usually embedded within your application if you use
Dext.Hosting, but it can also be compiled as a standalone tool.
dext <command> [arguments] [options]To see available commands:
dext helpLaunches the web-based dashboard for visual Dext management, configuration, and environment handling.
Syntax:
dext ui [--port <number>]Features:
- Projects: View recent projects and their statuses.
- Tests: View test results, code coverage metrics, and access full HTML reports.
- Settings: Configure global paths (Dext CLI, Code Coverage) and manage Delphi environments.
- Tools: Auto-install tools like CodeCoverage (via Settings).
Manage detected Delphi installations and configure which version to use for compilation.
Scans the Windows Registry for available Delphi installations and updates the global config.yaml.
Syntax:
dext env scanLists all configured Delphi installations and indicates the default one.
Syntax:
dext env listRuns the project's test suite. It automatically detects your .dproj (must contain "Test" in the name), builds it, and executes the resulting binary.
Syntax:
dext test [options]Options:
--project=<path>: Specifies the Delphi project file (.dproj) to build and test. If omitted, it searches for a*Test*.dprojin the current directory.--coverage: Enables code coverage analysis.- Builds the project with debug information (
-mapfile). - Runs tests using
CodeCoverage.exe. - Generates HTML and XML reports in
TestOutput/report. - Quality Gate: Checks
coverage.thresholdfromdext.jsonand fails the build if not met.
- Builds the project with debug information (
Configuration (dext.json):
Values in dext.json serve as defaults if CLI flags are not provided.
{
"test": {
"project": "Tests/MyProjectTests.dproj",
"reportDir": "build/reports",
"coverageThreshold": 80.0,
"coverageExclude": [
"*Dext.*",
"*ThirdParty*"
]
}
}The CLI integrates with Dext.Entity to manage comprehensive database schema migrations.
Applies all pending migrations to the database.
Syntax:
dext migrate:up [--source <path>]Options:
--source <path>(alias-s): Directory containing migration JSON files. Defaults to internal registry if omitted.
Reverts migrations. By default, it reverts the last applied migration.
Syntax:
dext migrate:down [--target <id>]Options:
--target <id>(alias-t): Reverts migrations sequentially until the specified Migration ID is reached (inclusive). If omitted, reverts only the last one.
Lists the status of all known migrations (Applied vs. Pending).
Syntax:
dext migrate:listOutput Example:
Migration Status:
-----------------
[Applied] 202501010000_InitialSchema
[Pending] 202501021230_AddUsers
Creates a new empty JSON migration file with a timestamped ID.
Syntax:
dext migrate:generate <name> [--path <dir>]Arguments:
<name>: A descriptive name for the migration (e.g.,AddCustomerTable).
Options:
--path <dir>(alias-p): Directory to save the file. Defaults to current directory.
Output:
Generates a file like 20260104223000_AddCustomerTable.json.
Generates a "Facade Unit" (Dext.pas) that acts as a central access point for types and constants declared across multiple core units. This simplifies the uses clause for end-users.
Syntax:
dext facade [--path <source-dir>] [--target <file>] [options]Options:
--path <dir>(alias-p): Source directory to scan for Pascal units. Defaults to current directory.--target <file>(alias-t): The target file where aliases will be injected. Defaults toDext.pasin the source directory.--exclude <units>(alias-x): Comma-separated list of unit names to exclude from generation.--dry-run: Preview changes without modifying the target file.--backup: Create a backup (.bak) of the target file before modification.--no-validate: Skip validation of delimiter tags (use with caution).--start-alias <tag>: Custom start delimiter for alias block.--end-alias <tag>: Custom end delimiter for alias block.--start-uses <tag>: Custom start delimiter for uses block.--end-uses <tag>: Custom end delimiter for uses block.
Example:
dext facade -p Sources\Core -t Sources\Core\Dext.pas --dry-run--help/-h/help: Displays the help screen with a list of available commands.
If compiling from source:
- Open
Sources/DextFramework.groupproj. - Build the
DextToolproject (found inApps/CLI). - Add the output directory to your system
PATH.