kgen alternatives and similar shards
Based on the "Project generators" category.
Alternatively, view kgen alternatives based on common mentions on social networks and blogs.
5.2 0.0 kgen VS generateGeneric tool for generating whole Crystal project structure, or any part of it during lifetime of project
Do you think we are missing an alternative of kgen or a related project?
Rails like command line for kemalyst
You can build the
kgen tool from source:
$ git clone [email protected]:kemalyst/kemalyst-generator.git $ cd kemalyst-generator/ $ shards install $ make
You should now have a bin/kgen file to run.
You can symlink this to a more global location like /usr/local/bin to make it easier to use:
$ ln -sf $(pwd)/bin/kgen /usr/local/bin/kgen
Optionally, you can use homebrew to install.
$ brew tap kemalyst/kgen $ brew install kgen
$ ./bin/kgen --help kgen [OPTIONS] SUBCOMMAND Kemalyst Generator Subcommands: c alias for console console g alias for generate generate i alias for init init m alias for migrate migrate w alias for watch watch Options: -h, --help show this help -v, --version show version
kgen init app [your_app] -d [pg | mysql | sqlite] -t [slang | ecr] --deps cd [your_app]
-d defaults to pg.
-t defaults to slang.
--deps will run
crystal deps for you.
This will generate a traditional web application:
- /config - Application and HTTP::Handler config's goes here. The database.yml and routes.cr are here.
- /lib - shards are installed here.
- /public - Default location for html/css/js files. The static handler points to this directory.
- /spec - all the crystal specs go here.
- /src - all the source code goes here.
Generate scaffolding for a resource:
kgen generate scaffold Post name:string body:text draft:bool
This will generate scaffolding for a Post:
- appends route to config/routes.cr
- appends navigation to src/layouts/_nav.slang
To test the demo app locally:
- Create a new Postgres or Mysql database called
- Configure your database with one of the following ways.
- Add it in
export DATABASE_URL=postgres://[username]:[password]@localhost:5432/[your_app]_developmentwhich overrides the
- Add it in
- Migrate the database:
kgen migrate up. You should see output like
Migrating db, current version: 0, target: [datetimestamp] OK [datetimestamp]_create_shop.sql
- Run the specs:
- Start your app:
- Then visit
kgen watch command uses Sentry to watch for any changes in your source files, recompiling automatically.
If you don't want to use Sentry, you can compile and run manually:
- Build the app
crystal build --release src/[your_app].cr
- Run with
See opened issues.
- Fork it ( https://github.com/kemalyst/kemalyst-generator/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request