Command-Line Interface (CLI) Reference¶
castlecraft-engineer
provides a command-line interface (CLI) for various development and operational tasks. This document outlines how to use the available CLI commands.
1. Invoking the CLI¶
The castlecraft-engineer
CLI is invoked using the engineer
command, which is made available when the package is installed.
You can invoke the CLI from the root of your project as follows:
Replace <command>
with one of the available commands detailed below and [options]
with any command-specific arguments.
2. Available Commands¶
The CLI is structured with sub-commands. Currently, the primary command available is bootstrap
.
bootstrap
Command¶
The bootstrap
command is used to initialize the database schema.
- Purpose: This command creates all necessary database tables based on the
SQLModel
metadata defined in your application. It's typically run once during the initial setup of your application or when new models are added and you need to update the schema in a development environment. For production environments, proper migration tools are usually recommended for schema changes after the initial setup. - Definition: The logic for this command is primarily located in
castlecraft_engineer.database.commands.bootstrap_schema
and it's made available to the CLI viacastlecraft_engineer.commands.argparser.add_bootstrap_schema_parser
. - Usage:
-
Details: When executed, this command will:
- Establish a database connection using the
SQL_ASYNC_CONNECTION_STRING
(orSQL_CONNECTION_STRING
if a synchronous version is targeted by the bootstrap logic) environment variable. - Collect all table metadata from
SQLModel
classes that have been imported and registered withSQLModel.metadata
. - Execute
SQLModel.metadata.create_all(engine)
to create these tables in the database if they don't already exist.
Ensure your
.env
file is correctly configured with the database connection string before running this command.Example Output (Conceptual):
- Establish a database connection using the