marmot
CLI entry point for Marmot.
Responsibilities:
- Parse config and CLI args, open the SQLite database
- Discover SQL directories and .sql files under src/
- Orchestrate per-file processing: read -> validate -> introspect -> codegen
- Detect output collisions, write generated modules, run gleam format
Detail work is delegated: config -> project.gleam, introspection -> sqlite.gleam, code generation -> codegen.gleam. This module only handles CLI I/O (args, env, file reading/writing, stderr, exit codes).
Types
pub type ResetError {
ResetDatabasePathIsDirectory(path: String)
ResetDatabaseDeleteError(path: String, message: String)
ResetMigrationError(error: migrations.MigrationError)
ResetSeedError(error: seeds.SeedError)
}
Constructors
-
ResetDatabasePathIsDirectory(path: String) -
ResetDatabaseDeleteError(path: String, message: String) -
ResetMigrationError(error: migrations.MigrationError) -
ResetSeedError(error: seeds.SeedError)
Values
pub fn check_duplicate_columns(
columns: List(@internal Column),
file_path: String,
) -> Result(Nil, Nil)
pub fn check_generated_column_names(
columns: List(@internal Column),
file_path: String,
) -> Result(Nil, Nil)
pub fn check_generated_parameter_names(
parameters: List(@internal Parameter),
file_path: String,
) -> Result(Nil, Nil)
pub fn contains_semicolon_outside_strings(sql: String) -> Bool
Check for semicolons outside of quoted SQL contexts, line comments, and block comments. Delegates to the tokenizer which already handles all quoting and comment styles correctly.
pub fn migrate(
database_path: String,
) -> Result(List(String), migrations.MigrationError)
pub fn migrate_from(
database_path: String,
migrations_dir: String,
) -> Result(List(String), migrations.MigrationError)
pub fn reset(
database_path: String,
) -> Result(#(List(String), List(String)), ResetError)
pub fn reset_from(
database_path: String,
migrations_dir: String,
seeds_dir: String,
) -> Result(#(List(String), List(String)), ResetError)
pub fn seed(
database_path: String,
) -> Result(List(String), seeds.SeedError)
pub fn seed_from(
database_path: String,
seeds_dir: String,
) -> Result(List(String), seeds.SeedError)
pub fn validate_sql(
trimmed: String,
file_path: String,
) -> Result(String, Nil)