Module: Prmd::CLI::Verify
- Extended by:
- Base
- Defined in:
- lib/prmd/cli/verify.rb
Overview
‘verify’ command module.
Class Method Summary collapse
-
.execute(options = {}) ⇒ void
Executes the ‘verify’ command.
-
.make_parser(options = {}) ⇒ OptionParser
Returns a OptionParser for parsing ‘verify’ command options.
Methods included from Base
execute, make_parser, noop_execute, parse_options, run
Class Method Details
.execute(options = {}) ⇒ void
This method returns an undefined value.
Executes the ‘verify’ command.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/prmd/cli/verify.rb', line 35 def self.execute( = {}) filename = .fetch(:argv).first _, data = try_read(filename) errors = Prmd.verify(data) unless errors.empty? errors.map! { |error| "#{filename}: #{error}" } if filename errors.each { |error| $stderr.puts(error) } exit(1) end result = [:yaml] ? data.to_yaml : JSON.pretty_generate(data) write_result result, end |
.make_parser(options = {}) ⇒ OptionParser
Returns a OptionParser for parsing ‘verify’ command options.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/prmd/cli/verify.rb', line 14 def self.make_parser( = {}) binname = .fetch(:bin, 'prmd') OptionParser.new do |opts| opts. = "#{binname} verify [options] <combined schema>" opts.on('-y', '--yaml', 'Generate YAML') do |y| yield :yaml, y end opts.on('-o', '--output-file FILENAME', String, 'File to write result to') do |n| yield :output_file, n end end end |