Class: GraphQL::Coverage::CLI
- Inherits:
-
Object
- Object
- GraphQL::Coverage::CLI
- Defined in:
- lib/graphql/coverage/cli.rb
Instance Method Summary collapse
-
#initialize(stdout:, stderr:) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv) ⇒ Object
Constructor Details
#initialize(stdout:, stderr:) ⇒ CLI
Returns a new instance of CLI.
8 9 10 11 |
# File 'lib/graphql/coverage/cli.rb', line 8 def initialize(stdout:, stderr:) @stdout = stdout @stderr = stderr end |
Instance Method Details
#run(argv) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/graphql/coverage/cli.rb', line 13 def run(argv) # @type var params: params params = { 'fail-on-uncovered': true, } args = OptionParser.new do |opts| opts. = <<~TXT Usage: graphql-coverage [options] [result file paths] Display the coverage result from multiple result files. Options: TXT opts.version = VERSION opts.on('-r', '--require PATH', 'Require a file.') do |path| require path end opts.on('--[no-]fail-on-uncovered', 'Fail when there are uncovered fields (default: true).') end.parse(argv, into: _ = params) Coverage.load(*args) ok = Coverage.report(output: stdout) if ok || !params[:'fail-on-uncovered'] return 0 else 1 end end |