Over at CloudSpokes we write a lot of ruby code (CloudSpokes.com runs on Heroku in Ruby with Database.com as the backend) for debugging, data migration, utilities and more. We typically just write a quick ruby class and run it from the command line to execute the script. However, I thought it might be cooler to write a cli for Force.com that I could distribute to the team.
So if you know a little ruby, the process isn't that difficult. All you need is the databasedoctom gem and thor, a simple tool for building self-documenting command line utilities in ruby. You then write your ruby code in the .thor file and execute if from the command line as you would any other cli.
So here are the available commands for the cli via thor's help command. Feel free to fork the code at github.
This video walks you through the functionality, setup and code for the cli in case you want more detail. The main code is below after the jump.
Assuming you have ruby installed, you need to install the databasedotcom and thor gems. It's very trivial and the instructions are available from their respective github repos. With thor, you can pass parameters to each task and setup method options. So for instance, in the thor file below, each task has an optional '-c' switch where you specify the connection file to load thus making it easy to connect to different orgs. If you omit the switch, the default databasedotcom.yml file is loaded.
The connection file is a simple yml file containing the parameters specified by the databasedotcom gem. You can have as many connection files as you would like to for production, developer and sandbox orgs and easily load different files using the '-c' switch. For instance, to run the query task against the org specified in the sandbox.yml file you would run: