Class: BitClust::Subcommand
Overview
Base class for bitclust subcommands.
Direct Known Subclasses
BitClust::Subcommands::AncestorsCommand, BitClust::Subcommands::ChmCommand, BitClust::Subcommands::ClassesCommand, BitClust::Subcommands::EPUBCommand, BitClust::Subcommands::ExtractCommand, BitClust::Subcommands::HtmlfileCommand, BitClust::Subcommands::InitCommand, BitClust::Subcommands::ListCommand, BitClust::Subcommands::LookupCommand, BitClust::Subcommands::MethodsCommand, BitClust::Subcommands::PreprocCommand, BitClust::Subcommands::PropertyCommand, BitClust::Subcommands::QueryCommand, BitClust::Subcommands::ServerCommand, BitClust::Subcommands::SetupCommand, BitClust::Subcommands::StatichtmlCommand, BitClust::Subcommands::UpdateCommand
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Subcommand.
14
15
16
17
18
19
20
|
# File 'lib/bitclust/subcommand.rb', line 14
def initialize
@parser = OptionParser.new
@parser.on_tail("-h", "--help", "Print this message and quit."){
$stderr.puts help
exit 0
}
end
|
Instance Method Details
#align_progress_bar_title(title) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/bitclust/subcommand.rb', line 56
def align_progress_bar_title(title)
size = title.size
if size > 14
title[0..13]
else
title + ' ' * (14 - size)
end
end
|
#error(message) ⇒ Object
41
42
43
44
|
# File 'lib/bitclust/subcommand.rb', line 41
def error(message)
$stderr.puts "#{File.basename($0, '.*')}: error: #{message}"
exit 1
end
|
#exec(argv, options) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/bitclust/subcommand.rb', line 30
def exec(argv, options)
prefix = options[:prefix]
error("no database given. Use --database option") unless prefix
if options[:capi]
@db = BitClust::FunctionDatabase.new(prefix)
else
@db = BitClust::MethodDatabase.new(prefix)
end
end
|
26
27
28
|
# File 'lib/bitclust/subcommand.rb', line 26
def help
@parser.help
end
|
#option_error(message) ⇒ Object
46
47
48
49
50
|
# File 'lib/bitclust/subcommand.rb', line 46
def option_error(message)
$stderr.puts message
$stderr.puts help
exit 1
end
|
#parse(argv) ⇒ Object
22
23
24
|
# File 'lib/bitclust/subcommand.rb', line 22
def parse(argv)
@parser.parse! argv
end
|
#srcdir_root ⇒ Object
52
53
54
|
# File 'lib/bitclust/subcommand.rb', line 52
def srcdir_root
Pathname.new(__FILE__).realpath.dirname.parent.parent
end
|