Module: Prmd::CLI::Combine

Extended by:
Base
Defined in:
lib/prmd/cli/combine.rb

Overview

‘combine’ command module.

Class Method Summary collapse

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 ‘combine’ command.

Examples:

Usage

Prmd::CLI::Combine.execute(argv: ['schema/schemata/api'],
                           meta: 'schema/meta.json',
                           output_file: 'schema/api.json',
                           type-as-string)

Parameters:

  • options (Hash<Symbol, Object>) (defaults to: {})


41
42
43
# File 'lib/prmd/cli/combine.rb', line 41

def self.execute(options = {})
  write_result Prmd.combine(options[:argv], options).to_s, options
end

.make_parser(options = {}) ⇒ OptionParser

Returns a OptionParser for parsing ‘combine’ command options.

Parameters:

  • options (Hash<Symbol, Object>) (defaults to: {})

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/prmd/cli/combine.rb', line 14

def self.make_parser(options = {})
  binname = options.fetch(:bin, 'prmd')

  OptionParser.new do |opts|
    opts.banner = "#{binname} combine [options] <file or directory>"
    opts.on('-m', '--meta FILENAME', String, 'Set defaults for schemata') do |m|
      yield :meta, m
    end
    opts.on('-o', '--output-file FILENAME', String, 'File to write result to') do |n|
      yield :output_file, n
    end
    opts.on('-t', '--type-as-string', 'Allow type as string') do |t|
      options[:type_as_string] = t
    end
  end
end