32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/ripper-tags.rb', line 32
def self.option_parser(options)
OptionParser.new do |opts|
opts.banner = "Usage: #{opts.program_name} [options] FILES..."
opts.version = version
opts.separator ""
opts.on("-f", "--tag-file (FILE|-)", "File to write tags to (default: `#{options.tag_file_name}')",
'"-" outputs to standard output') do |fname|
options.tag_file_name = fname
end
opts.on("--tag-relative[=OPTIONAL]", "Make file paths relative to the directory of the tag file") do |value|
options.tag_relative = value != "no"
end
opts.on("-R", "--recursive", "Descend recursively into subdirectories") do
options.recursive = true
end
opts.on("--exclude PATTERN", "Exclude a file, directory or pattern") do |pattern|
if pattern.empty?
options.exclude.clear
else
options.exclude << pattern
end
end
opts.on("--all-files", "Parse all files as ruby files, not just `*.rb' ones") do
options.all_files = true
end
opts.separator " "
opts.on("--format (emacs|json|custom)", "Set output format (default: vim)") do |fmt|
options.format = fmt
end
opts.on("-e", "--emacs", "Output Emacs format (default if `--tag-file' is `TAGS')") do
options.format = "emacs"
end
opts.on("--extra=FLAGS", "Specify extra flags for the formatter") do |flags|
flags = flags.split("")
operation = :add
if flags[0] == "+" || flags[0] == "-"
operation = :delete if flags.shift == "-"
else
options..clear
end
flags.each { |f| options..send(operation, f) }
end
opts.separator ""
opts.on_tail("-d", "--debug", "Output parse tree") do
options.debug = true
end
opts.on_tail("--debug-verbose", "Output parse tree verbosely") do
options.verbose_debug = true
end
opts.on_tail("-V", "--verbose", "Print additional information on stderr") do
options.verbose = true
end
opts.on_tail("--force", "Skip files with parsing errors") do
options.force = true
end
opts.on_tail("--list-kinds=LANG", "Print tag kinds that this parser supports and exit") do |lang|
if lang.downcase == "ruby"
puts((<<-OUT).gsub(/^ +/, ''))
c classes
f methods
m modules
F singleton methods
C constants
a aliases
OUT
exit
else
$stderr.puts "Error: language %p is not supported" % lang
exit 1
end
end
opts.on_tail("-v", "--version", "Print version information") do
puts opts.ver
exit
end
yield(opts, options) if block_given?
end
end
|