| Class | RailsInstaller::Command |
| In: |
lib/rails-installer/commands.rb
|
| Parent: | Object |
Parent class for command-line subcommand plugins for the installer. Each subclass must implement the command class method and should provide help text using the help method. Example (from Typo):
class SweepCache < RailsInstaller::Command
help "Sweep Typo's cache"
def self.command(installer, *args)
installer.sweep_cache
end
end
This implements a sweep_cache command that Typo users can access by running ‘typo sweep_cache /some/path’.
Subcommands that need arguments should use both ‘help’ and ‘flag_help’, and then use the args parameter to find their arguments. For example, the install subcommand looks like this:
class Install < RailsInstaller::Command
help "Install or upgrade APPNAME in PATH."
flag_help "[VERSION] [KEY=VALUE]..."
def self.command(installer, *args)
version = nil
args.each do |arg|
...
end
end
end
The command method implements this sub-command. It’s called by the command-line parser when the user asks for this sub-command.
flag_help sets the help text for any arguments that this sub-command accepts. It defaults to ’’.