Sha256: 9417d4bb45950815930c2c96c141c0db606e36647a37ad43d951060e23dcf746

Contents?: true

Size: 1.31 KB

Versions: 15

Compression:

Stored size: 1.31 KB

Contents

require_relative 'base'
require_relative '../commands/combine'

module Prmd
  module CLI
    # 'combine' command module.
    module Combine
      extend CLI::Base

      # Returns a OptionParser for parsing 'combine' command options.
      #
      # @param (see Prmd::CLI::Base#make_parser)
      # @return (see Prmd::CLI::Base#make_parser)
      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
        end
      end

      # Executes the 'combine' command.
      #
      # @example Usage
      #   Prmd::CLI::Combine.execute(argv: ['schema/schemata/api'],
      #                              meta: 'schema/meta.json',
      #                              output_file: 'schema/api.json')
      #
      # @param (see Prmd::CLI::Base#execute)
      # @return (see Prmd::CLI::Base#execute)
      def self.execute(options = {})
        write_result Prmd.combine(options[:argv], options).to_s, options
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
prmd-0.11.11 lib/prmd/cli/combine.rb
prmd-0.11.10 lib/prmd/cli/combine.rb
prmd-0.11.9 lib/prmd/cli/combine.rb
prmd-0.11.8 lib/prmd/cli/combine.rb
prmd-0.11.7 lib/prmd/cli/combine.rb
prmd-0.11.6 lib/prmd/cli/combine.rb
prmd-0.11.5 lib/prmd/cli/combine.rb
prmd-0.11.4 lib/prmd/cli/combine.rb
prmd-0.11.3 lib/prmd/cli/combine.rb
prmd-0.11.2 lib/prmd/cli/combine.rb
prmd-0.11.1 lib/prmd/cli/combine.rb
prmd-0.11.0 lib/prmd/cli/combine.rb
prmd-0.10.0 lib/prmd/cli/combine.rb
prmd-0.9.0 lib/prmd/cli/combine.rb
prmd-0.8.0 lib/prmd/cli/combine.rb