Kemalyst command line tool for console, init, generate (scaffolding), and watch kemalyst kemalyst-generator
0.8.2 Latest release released


Build Status

Rails like command line for kemalyst


You can build the kgen tool from source:

$ git clone
$ 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

Kemalyst Generator

  c         alias for console
  g         alias for generate
  i         alias for init
  m         alias for migrate
  w         alias for watch

  -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]

options: -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 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:

  • src/controllers/
  • src/models/
  • src/views/post/*
  • db/migrations/[datetimestamp]_create_post.sql
  • spec/controllers/
  • spec/models/
  • appends route to config/
  • appends navigation to src/layouts/_nav.slang

Run Locally

To test the demo app locally:

  1. Create a new Postgres or Mysql database called [your_app]_development
  2. Configure your database with one of the following ways.
  • Add it in config/database.yml
  • Run export DATABASE_URL=postgres://[username]:[password]@localhost:5432/[your_app]_development which overrides the config/database.yml.
  1. Migrate the database: kgen migrate up. You should see output like Migrating db, current version: 0, target: [datetimestamp] OK [datetimestamp]_create_shop.sql
  2. Run the specs: crystal spec
  3. Start your app: kgen watch
  4. Then visit

Note: The 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:

  1. Build the app crystal build --release src/[your_app].cr
  2. Run with ./[your_app]
  3. Visit


See opened issues.


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request


  github: kemalyst/kemalyst-generator
  version: ~> 0.8.2
License MIT
Crystal 0.23.1


Dependencies 8

  • cli ~> 0.5.1
    {'github' => 'mosop/cli', 'version' => '~> 0.5.1'}
  • icr master
    {'branch' => 'master', 'github' => 'TechMagister/crystal-icr'}
  • micrate
    {'github' => 'juanedi/micrate'}
  • mysql
    {'github' => 'crystal-lang/crystal-mysql'}
  • pg
    {'github' => 'will/crystal-pg'}
  • sentry~TechMagister change_cli
    {'branch' => 'change_cli', 'github' => 'TechMagister/sentry'}
  • sqlite3
    {'github' => 'crystal-lang/crystal-sqlite3'}
  • teeplate ~> 0.4.4
    {'github' => 'mosop/teeplate', 'version' => '~> 0.4.4'}

Development Dependencies 0

Dependents 0

Last synced .
search fire star recently