Class Mercenary::Command
In: lib/mercenary/command.rb
Parent: Object

Methods

Attributes

actions  [RW] 
aliases  [R] 
commands  [RW] 
description  [R] 
map  [R] 
name  [R] 
options  [RW] 
parent  [RW] 
syntax  [R] 
trace  [R] 

Public Class methods

Public: Creates a new Command

name - the name of the command parent - (optional) the instancce of Mercenary::Command which you wish to

         be the parent of this command

Returns nothing

Public Instance methods

Public: Add an action Proc to be executed at runtime

block - the Proc to be executed at runtime

Returns nothing

Public: Add version and help options to the command

opts - instance of OptionParser

Returns nothing

Public: Add an alias for this command‘s name to be attached to the parent

cmd_name - the name of the alias

Returns nothing

Public: Adds a subcommand

cmd_name - the name of the command block - a block accepting the new instance of Mercenary::Command to be

           modified (optional)

Returns nothing

Public: Sets the default command

command_name - the command name to be executed in the event no args are

               present

Returns the default command if there is one, `nil` otherwise

Public: Sets or gets the command description

description - the description of what the command does (optional)

Returns the description and sets it if an argument is present

Public: Execute all actions given the inputted args and options

argv - (optional) command-line args (sans opts) config - (optional) the Hash configuration of string key to value

Returns nothing

Public: Get the name of the current command plus that of

  its parent commands

Returns the full name of the command

Public: Run the command

argv - an array of string args opts - the instance of OptionParser config - the output config hash

Returns the command to be executed

Public: Check if this command has a subcommand

sub_command - the name of the subcommand

Returns true if this command is the parent of a command of name ‘sub_command’ and false otherwise

Public: Identify this command

Returns a string which identifies this command

Public: Get the full identity (name & version) of this command

Returns a string containing the name and version if it exists

Public: Fetch a Logger (stdlib)

level - the logger level (a Logger constant, see docs for more info)

Returns the instance of Logger

Public: Return all the names and aliases for this command.

Returns a comma-separated String list of the name followed by its aliases

Public: Adds an option switch

sym - the variable key which is used to identify the value of the switch

      at runtime in the options hash

Returns nothing

Public: Add this command‘s options to OptionParser and set a default

        action of setting the value of the option to the inputted hash

opts - instance of OptionParser config - the Hash in which the option values should be placed

Returns nothing

Public: Build a string containing a summary of the command

Returns a one-line summary of the command.

Public: Sets or gets the syntax string

syntax - the string which describes this command‘s usage syntax (optional)

Returns the syntax string and sets it if an argument is present

Public: Build a string containing the command name, options and any subcommands

Returns the string identifying this command, its options and its subcommands

Public: Sets or gets the command version

version - the command version (optional)

Returns the version and sets it if an argument is non-nil

[Validate]