As we mentioned earlier, along with the new AppBuilder came an open source command-line Ruby gem that lets you access most of the features of AppBuilder through an API. This allows you to write KRL with your favorite editor or IDE and then push your code to KNS from the command line or a plugin.
Installing the Gem
You can find the complete installation instructions here, but this is the basic process:
- Install Ruby (version 1.8.7 or later).
- Install the KRL gem (leave off
sudo if you're on Windows):
sudo gem install krl
- Use OAuth to connect to the KNS servers:
krl-connect
This will start a server on localhost:3009 that will walk you through the OAuth ceremony. Once that's all finished, you can kill the webserver (with Ctrl+C).
Once the gem is installed, you're ready to get started.
Basic commands
First off: krl help is the definitive guide to the gem. The command will list all the possible things you can do, along with their syntax. (Tip: the text is easiest to read if your terminal is at least 90 characters wide.)
Check out your app
Run krl apps to get a list of all your apps. That displays the ruleset ID and name of each app, along with your role on the app (owner or developer).

Note: Until you save your app in the new AppBuilder or with the command-line gem, its name won't show up in the list. You can see that in the screenshot--the third app in the list has only been edited in the old AppBuilder, so the name doesn't show up yet.
Once you know which app you want to work on, a krl checkout command with the ruleset ID, like this:
krl checkout a163x2
This will create a new folder in your working directory with the ruleset ID as the name. (You can rename the directory to something more descriptive if you like.)
Editing your app
You can edit the <rulesetId>.krl file with any editor you like. Near the end of this post are some plugins for common editors to do syntax highlighting and integrate with the command-line gem.
Committing your changes
Once you've made changes and want to commit them, simply run krl commit in the same directory as your .krl file. If your code had any parse errors, these will be displayed to you. If everything passed, the gem will tell you what version was committed:

If you (or another developer) makes some changes later on AppBuilder and you want to pull them down to your local copy, simply run krl update. Note that this will overwrite your local copy of the code; it doesn't do version-control-style conflict resolution for you.
Generating endpoints
The gem will let you create both test and production endpoints. Here are the various commands:
- Test bookmarklet:
krl test
- Test Infomation Card:
krl test infocard
- Production bookmarklet:
krl generate bookmarklet
- Production browser extension:
krl generate [firefox|chrome|ie] <name> <author> <descr>
- Production Information Card:
krl generate infocard <name>
Viewing older versions
If you ever want to go back and look at an older version of your app, simply run a krl show <version number> command. This will print out the KRL from that version to your console. You can even pipe it to a file to open in your editor (although you'll have to remove the first line, "KRL for version XX," if you want to use the file as a valid ruleset).
Running the krl versions command will list all the versions your app has been through, along with the timestamp, the developer who made the commit, and any notes associated with each version. That list will also tell you which version of the app is currently in production.
A note on the commands
Most of the functions must be performed inside a directory where you've checked out your app. commit and update are good examples of commands in that category. A few functions can be performed anywhere, since they're not specific to any particular app. Those are apps, checkout, create, and info. Refer to krl help for more information about where you can run the various commands.
Integrating with your favorite editor
The command-line gem is platform- and editor-agnostic, so you can create plugins for any editor or IDE the offers a programmable interface. Here are a few of the ones that have been developed so far:
Emacs
This Emacs mode provides syntax highlighting for KRL. Find the .el file here.

TextMate
This TextMate bundle maps Cmd+K to save the app and then commit it. Find it here.

Vim
This Vim plugin enables syntax highlighting and intelligent indentation of KRL files. Get the .vim files here.

Growl and libnotify integration
You can have bash notify you when the krl commit command finishes running. See the solution here for Growl (Mac OS X) or here for libnotify (Linux).

Other editors and IDEs
Have you created a package for any other editors or IDEs? Leave a link in the comments!
The gem is open source
The Ruby code for the KRL command-line gem is open source. You can find it on the Kynetx github account.
If you have any issues with the gem or if you'd like to offer improvements, please do! You can submit bug fixes on the Issues tab on github. Or (even better) you can fork the code, fix the bug you found, and then send us a pull request.