Sha256: 86584b527d931fb1492bd7be91313f16413359f01de696613d7a3107cc4288e2

Contents?: true

Size: 771 Bytes

Versions: 4

Compression:

Stored size: 771 Bytes

Contents

command 'schema' do |c|
  c.syntax = "brief schema"
  c.description = "view information about the schema"

  Brief.default_cli_options(c)

  c.option '--output FILE', String, 'Output the contents to the specified file'
  c.option '--all-models', 'Include all models, not just those that have documents'
  c.option '--list-types', 'Only list the types'

  Brief.cli_action(c) do |args, options|
    schema_map = Brief.case.schema_map(options.all_models)

    output = if args.empty?
      schema_map.to_json
    else
      detail = schema_map.fetch(args.first.downcase, nil)
      detail.to_json if detail
    end

    if options.output
      Pathname(options.output).open "w+" do |fh|
        fh.write(output.chomp)
      end
    else
      puts output
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brief-1.9.0 lib/brief/cli/schema.rb
brief-1.8.12 lib/brief/cli/schema.rb
brief-1.8.11 lib/brief/cli/schema.rb
brief-1.8.10 lib/brief/cli/schema.rb