Module | Mongrel::Command::Base
In: | lib/mongrel/command.rb

A Command pattern implementation used to create the set of command available to the user from Mongrel. The script uses objects which implement this interface to do the user‘s bidding.

### Methods

configure failure help new options run valid? valid_dir? valid_exists? valid_file? valid_group? valid_user? validate

### Attributes

done_validating | [R] |
original_args | [R] |
valid | [R] |

### Public Class methods

new(options={})

Called by the subclass to setup the command and parse the argv arguments. The call is destructive on argv since it uses the OptionParser#parse! function.

### Public Instance methods

configure()
failure(message)

Just a simple method to display failure until something better is developed.

help()

Returns a help message. Defaults to OptionParser#help which should be good.

options(opts)

Called by the implemented command to set the options for that command. Every option has a short and long version, a description, a variable to set, and a default value. No exceptions.

run()

Runs the command doing it‘s job. You should implement this otherwise it will throw a NotImplementedError as a reminder.

valid?(exp, message)

Validates the given expression is true and prints the message if not, exiting.

valid_dir?(file, message)

Validates that the given directory exists

valid_exists?(file, message)

Validates that a file exists and if not displays the message

valid_file?(file, message)

Validates that the file is a file and not a directory or something else.

valid_group?(group)
valid_user?(user)
validate()

Returns true/false depending on whether the command is configured properly.

[Validate]