add --output-dir option and begin on Gcovinator.run()

This commit is contained in:
Josh Holtrop 2017-01-14 11:37:58 -05:00
parent d363948e73
commit 7a34aa2c65
2 changed files with 24 additions and 7 deletions

View File

@ -1,5 +1,14 @@
require_relative "gcovinator/version" require_relative "gcovinator/version"
module Gcovinator module Gcovinator
# Your code goes here...
class << self
def run(build_dir, source_dirs, files, output_dir)
source_dirs = ["."] if source_dirs.empty?
files = Dir["#{build_dir}/**/*.gcda"] if files.empty?
end
end
end end

View File

@ -5,10 +5,12 @@ module Gcovinator
module Cli module Cli
class << self class << self
def run(argv) def run(argv)
argv = argv.dup argv = argv.dup
build_dir = "." build_dir = "."
source_dirs = [] source_dirs = []
output_dir = "coverage"
OptionParser.new do |opts| OptionParser.new do |opts|
@ -16,7 +18,7 @@ module Gcovinator
opts.separator "" opts.separator ""
opts.separator "Pass paths to .gcda files as FILES." opts.separator "Pass paths to .gcda files as FILES."
opts.separator "If no FILES are specified, gcovinator looks for all .gcda files recursively under the build directory" opts.separator "If no FILES are specified, gcovinator looks for all .gcda files recursively under the build directory."
opts.separator "" opts.separator ""
opts.separator "Options:" opts.separator "Options:"
@ -24,6 +26,15 @@ module Gcovinator
build_dir = b build_dir = b
end end
opts.on_tail("-h", "--help", "Show this help.") do
puts opts
exit 0
end
opts.on("-o OUTPUTDIR", "--output-dir OUTPUTDIR", "Specify output directory. HTML reports will be written to this directory. Defaults to 'coverage' if not specified.") do |o|
output_dir = o
end
opts.on("-s SRCDIR", "--source-dir SRCDIR", "Specify a source directory. Reports will only be generated for sources under a specified source directory. Multiple source directories may be specified. Defaults to '.' if not specified.") do |s| opts.on("-s SRCDIR", "--source-dir SRCDIR", "Specify a source directory. Reports will only be generated for sources under a specified source directory. Multiple source directories may be specified. Defaults to '.' if not specified.") do |s|
source_dirs << s source_dirs << s
end end
@ -33,14 +44,11 @@ module Gcovinator
exit 0 exit 0
end end
opts.on_tail("-h", "--help", "Show this help.") do
puts opts
exit 0
end
end.parse!(argv) end.parse!(argv)
Gcovinator.run(build_dir, source_dirs, argv)
end end
end end
end end