Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use the CLI #186

Open
ghost opened this issue Sep 13, 2020 · 5 comments
Open

Document how to use the CLI #186

ghost opened this issue Sep 13, 2020 · 5 comments

Comments

@ghost
Copy link

ghost commented Sep 13, 2020

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.

@anykeyh
Copy link
Owner

anykeyh commented Nov 21, 2020

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.

@Troplo
Copy link

Troplo commented Jan 12, 2022

help

@anykeyh
Copy link
Owner

anykeyh commented Jan 13, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@anykeyh @Troplo and others