Module: Prmd::CLI::Doc
- Extended by:
- Base
- Defined in:
- lib/prmd/cli/doc.rb
Overview
‘doc’ command module.
Class Method Summary collapse
-
.execute(options = {}) ⇒ void
Executes the ‘doc’ command.
-
.make_parser(options = {}) ⇒ OptionParser
Returns a OptionParser for parsing ‘doc’ command options.
-
.set_option(options, key, value) ⇒ void
Overwritten to support :settings merging.
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 ‘doc’ command.
59 60 61 62 63 64 65 66 |
# File 'lib/prmd/cli/doc.rb', line 59 def self.execute( = {}) filename = .fetch(:argv).first template = File.('templates', File.dirname(__FILE__)) _, data = try_read(filename) schema = Prmd::Schema.new(data) opts = .merge(template: template) write_result Prmd.render(schema, opts), end |
.make_parser(options = {}) ⇒ OptionParser
Returns a OptionParser for parsing ‘doc’ command options.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/prmd/cli/doc.rb', line 15 def self.make_parser( = {}) binname = .fetch(:bin, 'prmd') OptionParser.new do |opts| opts. = "#{binname} doc [options] <combined schema>" opts.on('-s', '--settings FILENAME', String, 'Config file to use') do |s| settings = Prmd.load_schema_file(s) || {} = HashHelpers.deep_symbolize_keys(settings) yield :settings, end opts.on('-c', '--content-type application/json', String, 'Content-Type header') do |c| yield :content_type, c end opts.on('-o', '--output-file FILENAME', String, 'File to write result to') do |n| yield :output_file, n end opts.on('-p', '--prepend header,overview', Array, 'Prepend files to output') do |p| yield :prepend, p end end end |
.set_option(options, key, value) ⇒ void
This method returns an undefined value.
Overwritten to support :settings merging.
43 44 45 46 47 48 49 |
# File 'lib/prmd/cli/doc.rb', line 43 def self.set_option(, key, value) if key == :settings .replace(value.merge()) else super end end |