class Gtmtech::Crypto::Subcommand

Attributes

global_options[RW]
helptext[RW]
options[RW]

Public Class Methods

all_options() click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 24
def self.all_options 
  options = @@global_options.dup
  options += self.options if self.options
  { :options => options }
end
description() click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 83
def self.description
  "no description"
end
error(message) click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 103
def self.error message
  puts "Error:"
  puts message
  exit 1
end
execute() click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 91
def self.execute
  raise StandardError, "This command is not implemented yet (#{self.to_s.split('::').last})"
end
find(commandname = "unknown_command") click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 30
def self.find commandname = "unknown_command"
  begin
    require "gtmtech/crypto/subcommands/#{commandname.downcase}"
  rescue Exception => e
    require "gtmtech/crypto/subcommands/unknown_command"
    return Gtmtech::Crypto::Subcommands::UnknownCommand
  end          
  command_module = Module.const_get('Gtmtech').const_get('Crypto').const_get('Subcommands')
  command_class = Utils.find_closest_class :parent_class => command_module, :class_name => commandname
  if command_class
    command_class
  else
    require "gtmtech/crypto/subcommands/unknown_command"
    Gtmtech::Crypto::Subcommands::UnknownCommand
  end
end
hidden?() click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 99
def self.hidden?
  false
end
parse() click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 47
def self.parse

  me = self
  all = self.all_options

  @@options = Trollop::options do

    version "gtmtech-crypto version " + Gtmtech::Crypto::VERSION.to_s
    banner "#{me.usage}\n\n"

    all[:options].each do |available_option|

      skeleton = {:description => "",
                  :short => :none}

      skeleton.merge! available_option
      opt skeleton[:name], 
          skeleton[:desc] || skeleton[:description],  #legacy plugins
          :short => skeleton[:short], 
          :default => skeleton[:default], 
          :type => skeleton[:type]

    end

  end

end
prettyname() click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 95
def self.prettyname
  Utils.snakecase self.to_s.split('::').last
end
usage() click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 79
def self.usage
  "Usage: \ncrypto #{self.prettyname} [global-options] [options]\nDescription: #{self.description}"
end
validate(args) click to toggle source
# File lib/gtmtech/crypto/subcommand.rb, line 75
def self.validate args
  args
end