Building Ruby GLI Apps in Sublime Text 2

May - 2014

I'm switching to Ruby for my main coding language. When I used to code in Perl, I started command line apps with my own little framework. I pieced together over the years to provide a basic configuration, logging, etc... functionality that I use in every app. Being new to language, I don't have the knowledge or skill to create one yet in Ruby. This is not a problem since I found the excellent Git-Like Interface Command Line Parser (aka "GLI").

From the description:

GLI is the best way to make a “command-suite” command-line application, e.g. one like git. GLI allows you to make a polished, easy-to-maintain command-line application without a lot of syntax, but without restricting you in any way from the power of OptionParser.


This is for a project file that looks like this:

  {
    "folders": [
      {
        "path": "."
      }
    ]
    ,
    "build_systems": [
      {
        "env":{
          "PATH":"${HOME}/.rvm/bin:${PATH}"
        },
        "name": "Bundle exec bin/project_name run",
        "working_dir": "${project_path:${folder}}",
        "cmd": ["rvm-auto-ruby","-S", "bundle", "exec", "bin/$project_base_name", "run"]
      }
    ]
  }


Note that when run with from Sublime Text with this, you'll see something likes for File.expand_path(File.dirname($0)):

/Users/alans/working/player_headshot_thumbnail_viewer/bin

If bundle exec bin/player_headshot_thumbnail_viewer run is run on the command line while in the root of the app, the same output will show up.

However, if the working directory is moved to the apps "bin" directory and the command is /Users/alans/.rvm/gems/ruby-2.1.0/bin and you're using rvm, the output will be:

/Users/alans/.rvm/gems/ruby-2.1.0/bin