clear
clear copied to clipboard
Document how to use the CLI
The Clear manual mentions a migration CLI, but I cannot figure out how to access it. Building with either src/clear.cr or src/clear/cli.cr as an entrypoint produces an executable that does nothing.
Crystal is compiled software so it's hard to get information over your code (e.g. migrations files, model description) without compiling your code first.
To use the CLI, you need to use
# in your application entry point
Clear.with_cli do
# your startup code goes here
Server.start #example
end
Then you can call crystal path/to/your/entrypoint.cr -- clear --help
For now, CLI is still very basic but hopefully I will fix this soon.
help
help
help
CLI is good for seed + migration currently.
migrate:
$(CRYSTAL_RUN) src/endpoints/server.cr -- clear migrate
seed:
$(CRYSTAL_RUN) src/endpoints/server.cr -- clear seed
this is an example of one of my project using the CLI
Your bootstrap point must be written like this:
Clear.with_cli do
Kemal.run # example
end
So far the CLI implementation is lacking a bit of features; it can manage migrations but you can run them manually and/or manage you own CLI implementation:
Clear::Migration::Manager.instance.apply_all