Module: Lingo::Ctl

Extended by:
Ctl, TextUtils
Included in:
Ctl
Defined in:
lib/lingo/ctl.rb,
lib/lingo/ctl/files.rb,
lib/lingo/ctl/other.rb,
lib/lingo/ctl/analysis.rb

Constant Summary collapse

USAGE =
<<-EOT
Usage: #{PROG} <command> [arguments] [options]
   #{PROG} [-h|--help] [--version]
EOT

Constants included from TextUtils

TextUtils::DEFAULT_MODE, TextUtils::GZIP_RE, TextUtils::STDIN_EXT, TextUtils::STDOUT_EXT

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cmd(name, short, desc, args = nil, default = nil) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/lingo/ctl.rb', line 53

def self.cmd(name, short, desc, args = nil, default = nil)
  if name.is_a?(Array)
    m, f, k = name
    name, short = "#{m}#{k}", "#{f}#{short}"
    class_eval %Q{private; def do_#{name}; #{m}(:#{k}); end}
  end

  if args
    desc = [desc, args = "Arguments: #{args}"]
    args << " (Default: #{default})" if default
  end

  COMMANDS[name], ALIASES[short] = desc, name
end

Instance Method Details

#ctlObject



48
49
50
51
# File 'lib/lingo/ctl.rb', line 48

def ctl
  parse_options
  send("do_#{ALIASES[ARGV.shift]}")
end