funsies/cli_project/project
A set of utilities to work within a Gleam project and to make the CLI work. Some functions are from the Squirre repo, thanks so much!
These help me orient myself within a gleam project, and also the creation of the generate.gleam
file which is used to actually generate the code.
Functions
pub fn create_files(
input: Dict(String, String),
) -> Result(Nil, FileError)
This has a bad name. Basically what it does is create the generate file, which is used to generate the types, decoders, and the insert
function.
The reason the insert function has to be generated is because it felt like the easiest way to maintain complete type-safety.
pub fn find_schema_files() -> Result(Dict(String, String), Nil)
Finds the schema files (looks in src/schema/*.gleam), and returns them as a dictionary of the file_path and the name of the schema (by removing everything except hte final clause without the extensions)
pub fn name() -> Result(String, Nil)
Returns the project’s name, read from the gleam.toml
file.
FROM SQUIRREL PROJECT, TYSM
pub fn src() -> String
Finds the path of the project’s src
directory.
This recursively walks up from the current directory until it finds a
gleam.toml
and builds it from there.
FROM SQUIRRLE PROJECT, TYSM