Generates starter Ash Resource modules for AshScylla.
Summary
Functions
Parses generator command arguments.
Same as parse_args/1 but also accepts options from CLI flags.
Renders CQL CREATE TABLE and CREATE INDEX statements for a table.
Renders an Ash Resource template as a string.
Returns the generated resource file path for a resource name.
Writes a generated resource file to lib/<app>/resources/<resource>.ex.
Functions
@spec parse_args([String.t()]) :: {:ok, module(), [{atom(), atom()}], keyword()} | {:error, String.t()}
Parses generator command arguments.
Accepts a resource name (optionally domain-prefixed) and a comma-separated
list of name:type attribute pairs.
Examples
AshScylla.ResourceGenerator.parse_args([
"MyResource",
"user_id:uuid, name:string, age:int"
])
AshScylla.ResourceGenerator.parse_args([
"MyApp.MyDomain.MyResource",
"user_id:uuid, name:string"
])Options (as keyword list, passed from the Mix task):
:domain- Domain module to include in the generated resource:resource- Fully-qualified resource module name (overrides the positional name argument)
@spec parse_args( [String.t()], keyword() ) :: {:ok, module(), [{atom(), atom()}], keyword()} | {:error, String.t()}
Same as parse_args/1 but also accepts options from CLI flags.
Options
:domain- Domain module to include in the generated resource:resource- Fully-qualified resource module name (overrides positional arg)
Renders CQL CREATE TABLE and CREATE INDEX statements for a table.
Returns a list of CQL statement strings.
Renders an Ash Resource template as a string.
Options
:repo_module- The repo module to reference (defaults to<AppName>.Repo):domain- Domain module to include viadomainoption in the resource
Example
AshScylla.ResourceGenerator.render_resource(
MyApp.User,
[user_id: :uuid, name: :string, age: :integer],
repo_module: MyApp.Repo
)
AshScylla.ResourceGenerator.render_resource(
MyApp.MyDomain.User,
[user_id: :uuid, name: :string],
domain: MyApp.MyDomain,
repo_module: MyApp.Repo
)
Returns the generated resource file path for a resource name.
Writes a generated resource file to lib/<app>/resources/<resource>.ex.
Options
:domain- Domain module to include in the generated resource:repo_module- The repo module to reference