From 031681f8fc202243bcfd77298ff6750116bfd9d4 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 14 Jan 2017 11:23:51 -0500 Subject: [PATCH] add initial Cli module --- lib/gcovinator/cli.rb | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lib/gcovinator/cli.rb diff --git a/lib/gcovinator/cli.rb b/lib/gcovinator/cli.rb new file mode 100644 index 0000000..db901f9 --- /dev/null +++ b/lib/gcovinator/cli.rb @@ -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