add initial Cli module

This commit is contained in:
Josh Holtrop 2017-01-14 11:23:51 -05:00
parent 2f63d5840c
commit 031681f8fc

47
lib/gcovinator/cli.rb Normal file
View File

@ -0,0 +1,47 @@
require "gcovinator"
require "optparse"
module Gcovinator
module Cli
class << self
def run(argv)
argv = argv.dup
build_dir = "."
source_dirs = []
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options] [FILES]"
opts.separator ""
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 ""
opts.separator "Options:"
opts.on("-b BUILDDIR", "--build-dir BUILDDIR", "Specify the build directory. Source file paths in object/gcov files will be relative to this directory. Defaults to '.' if not specified.") do |b|
build_dir = b
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|
source_dirs << s
end
opts.on_tail("--version", "Show version") do
puts "gcovinator, version #{Gcovinator::VERSION}"
exit 0
end
opts.on_tail("-h", "--help", "Show this help.") do
puts opts
exit 0
end
end.parse!(argv)
end
end
end
end