Executable

DESCRIPTION

The Executable mixin is a very quick and and easy way to make almost any class usable via a command line interface. It simply uses writer methods as option setters, and the first command line argument as the method to call, with the subsequent arguments passed to the method.

FEATURES

  • Super easy to use, just mixin.

  • Public writters become CLI options.

  • Public methods become subcommands.

RELEASE NOTES

Please see HISTORY file.

SYNOPSIS

Simply mixin Executable, then call #execute_command.

class X
  include Executable
  attr_accessor :quiet
  def bread(*args)
    ["BREAD", quiet, *args]
  end
  def butter(*args)
    ["BUTTER", quiet, *args]
  end
end

x = X.new

x.execute_command("butter yum")
=> ["BUTTER", nil, "yum"]

x.execute_command("bread --quiet")
=> ["BREAD", true]

See RDocs for more information.

INSTALL

$ sudo gem install executable

(Apache 2.0)

Copyright © 2009 Thomas Sawyer

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this program except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.