To read a linkable version of this README, see here.

Description

Boson is a command/task framework with the power to turn any ruby method into a full-fledged executable with options. Some unique features that differentiate it from rake and thor include being usable from irb and the commandline, optional automated views generated by hirb and allowing libraries to be written as plain ruby. For my libraries that use this, see irbfiles. Works with all major ruby versions.

Features

Creating Command Libraries

See Boson::FileLibrary or here.

Irb Example

To use in irb, drop this in your ~/.irbrc:

require 'boson'
Boson.start

Having done that, let's start up irb:

bash> irb
Loaded library core
Loaded library web_core

# List default libraries
>> libraries
+----------+----------+------+--------------+
| name     | commands | gems | library_type |
+----------+----------+------+--------------+
| core     | 6        |      | module       |
| web_core | 3        |      | module       |
+----------+----------+------+--------------+
2 rows in set

# List default commands
>> commands
+--------------+----------+-------+--------------------------------------------+-----------------------------------------------------------------------------+
| full_name    | lib      | alias | usage                                      | description                                                                 |
+--------------+----------+-------+--------------------------------------------+-----------------------------------------------------------------------------+
| usage        | core     |       | [name][--verbose]                          | Print a command's usage                                                     |
| libraries    | core     |       | [query=''][--index] [--query_fields=A,B,C] | List or search libraries                                                    |
| render       | core     |       | [object] [options={}]                      | Render any object using Hirb                                                |
| load_library | core     |       | [library][--verbose] [--reload]            | Load/reload a library                                                       |
| commands     | core     |       | [query=''][--index] [--query_fields=A,B,C] | List or search commands                                                     |
| menu         | core     |       | [output] [options={}] [&block]             | Provide a menu to multi-select elements from a given array                  |
| get          | web_core |       | [url]                                      | Gets the body of a url                                                      |
| install      | web_core |       | [url][--force] [--name=NAME]               | Installs a library by url. Library should then be loaded with load_library. |
| browser      | web_core |       | [*urls]                                    | Opens urls in a browser                                                     |
+--------------+----------+-------+--------------------------------------------+-----------------------------------------------------------------------------+
9 rows in set

# Boson commands can behave like shell commands:

# Basic help
>> commands '-h'
commands [query=''][--index] [--query_fields=A,B,C]

# Search the lib column for web
>> commands 'web -q=lib' # or 'web --query_fields=lib'
+-----------+----------+-------+------------------------------+-----------------------------------------------------------------------------+
| full_name | lib      | alias | usage                        | description                                                                 |
+-----------+----------+-------+------------------------------+-----------------------------------------------------------------------------+
| get       | web_core |       | [url]                        | Gets the body of a url                                                      |
| install   | web_core |       | [url][--force] [--name=NAME] | Installs a library by url. Library should then be loaded with load_library. |
| browser   | web_core |       | [*urls]                      | Opens urls in a browser                                                     |
+-----------+----------+-------+------------------------------+-----------------------------------------------------------------------------+
3 rows in set

Commandline Example

# Just like in irb
 bash> boson libraries
 +----------+----------+------+--------------+
 | name     | commands | gems | library_type |
 +----------+----------+------+--------------+
 | core     | 6        |      | module       |
 | web_core | 3        |      | module       |
 +----------+----------+------+--------------+
 2 rows in set

 # Let's install another library
 bash> boson install http://github.com/cldwalker/irbfiles/raw/master/boson/commands/public/irb_core.rb
 Saved to /Users/bozo/.boson/commands/irb_core.rb

 # Let's start irb ...
 bash> irb

 >> commands
 +-------------------------------+----------+------------+--------------------------------------------+-----------------------------------------------------------------------------+
 | full_name                     | lib      | alias      | usage                                      | description                                                                 |
 +-------------------------------+----------+------------+--------------------------------------------+-----------------------------------------------------------------------------+
 | usage                         | core     |            | [name][--verbose]                          | Print a command's usage                                                     |
 | libraries                     | core     |            | [query=''][--index] [--query_fields=name]  | List or search libraries                                                    |
 | render                        | core     |            | [object] [options={}]                      | Render any object using Hirb                                                |
 | load_library                  | core     |            | [library][--verbose] [--reload]            | Load/reload a library                                                       |
 | commands                      | core     |            | [query=''][--index] [--query_fields=A,B,C] | List or search commands                                                     |
 | menu                          | core     |            | [output] [options={}] [&block]             | Provide a menu to multi-select elements from a given array                  |
 | get                           | web_core |            | [url]                                      | Gets the body of a url                                                      |
 | install                       | web_core |            | [url][--force] [--name=NAME]               | Installs a library by url. Library should then be loaded with load_library. |
 | browser                       | web_core |            | [*urls]                                    | Opens urls in a browser                                                     |
 | irb_pop_workspace             | irb_core | popws      |                                            | Pops current workspace and changes to next workspace in context             |
 | irb_require                   | irb_core |            |                                            | Evals file like require line by line                                        |
 | public                        | irb_core |            |                                            | Works same as module#public                                                 |
 | private                       | irb_core |            |                                            | Works same as module#private                                                |
 | irb                           | irb_core |            |                                            | Starts a new workspace/subsession                                           |
 | irb_push_workspace            | irb_core | pushws     |                                            | Creates a workspace for given object and pushes it into the current context |
 | irb_load                      | irb_core |            |                                            | Evals file like load line by line                                           |
 | irb_change_workspace          | irb_core | cws        |                                            | Changes current workspace to given object                                   |
 | irb_source                    | irb_core | source     |                                            | Evals full path file line by line                                           |
 | irb_jobs                      | irb_core | jobs       |                                            | List workspaces/subsessions                                                 |
 | irb_fg                        | irb_core | fg         |                                            | Switch to a workspace/subsession                                            |
 | irb_help                      | irb_core | help       |                                            | Ri based help                                                               |
 | irb_kill                      | irb_core | kill       |                                            | Kills a given workspace/subsession                                          |
 | include                       | irb_core |            |                                            | Works same as module#include                                                |
 | irb_exit                      | irb_core | exit       |                                            | Kills the current workspace/subsession                                      |
 | irb_workspaces                | irb_core | workspaces |                                            | Array of workspaces for current context                                     |
 | irb_context                   | irb_core | conf       |                                            | Displays configuration for current workspace/subsession                     |
 | install_alias_method          | irb_core |            |                                            | Aliases given method, allows lazy loading of dependent file                 |
 | irb_current_working_workspace | irb_core | cwws       |                                            | Prints current workspace                                                    |
 +-------------------------------+----------+------------+--------------------------------------------+-----------------------------------------------------------------------------+
 28 rows in set

 # Sweet! Now we have a list and description of commands that come with irb.

Todo

Bugs/Issues

Please report them on github.

Motivation

My tagging obsession from the ruby console.

Links

Credits

Boson stands on the shoulders of these people and their ideas: