Creating Executables

Creating executables with Alki is very straightforward. Below are some guidelines for how to do so.

Without a gemspec

If your project isn’t a gem, and doesn’t have a gemspec, executables should go in bin and should include these two lines before require-ing any other files.

require 'bundler/setup'
require 'alki/bin'

After that you can use your library.

bin/my_exe
require 'bundler/setup'
require 'alki/bin'

require 'my_project'

MyProject.new.cli.run
$ bin/my_exe
...

With a gemspec

If your project is a gem, it should be done differently.

First, in your gemspec, set the bindir option to 'exe' (not 'bin'). Also if automatically setting the executables option, make sure it is looking for files in exe, not bin. This is done to avoid collisions between your raw executable files, and binstubs generated by bundler.

Executables should be placed in exe, not bin.

Finally, once your gemspec is setup, run bundle binstubs <gem name> where <gem name> is whatever you set spec.name to in your gemspec.

Once done, you should have binstubs in bin for each executable you have in exe. These are what you should run for testing/development. If you add new executables to exe, just run bundle install to generate new binstubs for them.

Second, executables in exe shouldn’t require any extra files other then the project files they need to run (do not require bundle/setup or alki/bin).

exe/my_exe
require 'my_gem'

MyGem.new.cli.run
$ bundle binstubs my_gem
$ bin/my_exe
...

results matching ""

    No results matching ""