Class: Ergane::Tool

Inherits:
Command show all
Defined in:
lib/ergane/tool.rb

Instance Attribute Summary

Attributes inherited from Command

#options

Class Method Summary collapse

Methods inherited from Command

#abbreviate_path, #args, command_name, command_name=, #initialize, #run, subcommands, terms

Methods included from DSL::CommandDSL

#aliases, #argument, #command, #description, #flag, #option

Methods included from Concerns::OptionHandling

included

Methods included from Concerns::Inheritance

included

Constructor Details

This class inherits a constructor from Ergane::Command

Class Method Details

.command_class(klass = nil) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/ergane/tool.rb', line 8

def command_class(klass = nil)
  if klass
    @command_class = klass
    wire_command_class(klass)
  else
    @command_class
  end
end

.inherited(subclass) ⇒ Object



41
42
43
44
# File 'lib/ergane/tool.rb', line 41

def inherited(subclass)
  super
  create_command_base(subclass) if self == Tool
end

.load_commands(*patterns) ⇒ Object



35
36
37
38
39
# File 'lib/ergane/tool.rb', line 35

def load_commands(*patterns)
  patterns.flatten.each do |pattern|
    Dir[pattern].sort.each { |file| require file }
  end
end

.start(argv = ARGV) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/ergane/tool.rb', line 25

def start(argv = ARGV)
  Runner.new(self, argv.dup).execute
rescue Interrupt
  $stderr.puts "\nAborted."
  exit 130
rescue Ergane::Error => e
  $stderr.puts e.message
  exit 1
end

.tool_name(name = nil) ⇒ Object



17
18
19
# File 'lib/ergane/tool.rb', line 17

def tool_name(name = nil)
  name ? (self.command_name = name) : command_name
end

.version(ver = nil) ⇒ Object



21
22
23
# File 'lib/ergane/tool.rb', line 21

def version(ver = nil)
  ver ? (@version = ver) : @version
end