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.
15
16
17
18
19
20
21
|
# File 'lib/bitclust/subcommand.rb', line 15
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
57
58
59
60
61
62
63
64
|
# File 'lib/bitclust/subcommand.rb', line 57
def align_progress_bar_title(title)
size = title.size
if size > 14
title[0..13]
else
title + ' ' * (14 - size)
end
end
|
#error(message) ⇒ Object
42
43
44
45
|
# File 'lib/bitclust/subcommand.rb', line 42
def error(message)
$stderr.puts "#{File.basename($0, '.*')}: error: #{message}"
exit 1
end
|
#exec(argv, options) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/bitclust/subcommand.rb', line 31
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
|
27
28
29
|
# File 'lib/bitclust/subcommand.rb', line 27
def help
@parser.help
end
|
#option_error(message) ⇒ Object
47
48
49
50
51
|
# File 'lib/bitclust/subcommand.rb', line 47
def option_error(message)
$stderr.puts message
$stderr.puts help
exit 1
end
|
#parse(argv) ⇒ Object
23
24
25
|
# File 'lib/bitclust/subcommand.rb', line 23
def parse(argv)
@parser.parse! argv
end
|
#srcdir_root ⇒ Object
53
54
55
|
# File 'lib/bitclust/subcommand.rb', line 53
def srcdir_root
Pathname.new(__FILE__).realpath.dirname.parent.parent
end
|