Class: Chemicalml::Cli::InspectCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/chemicalml/cli/inspect_command.rb

Overview

chemicalml inspect <file> — print a tree-style summary of the document: element names, ids, nested children.

Instance Attribute Summary

Attributes inherited from Command

#logger

Instance Method Summary collapse

Methods inherited from Command

#initialize, run

Constructor Details

This class inherits a constructor from Chemicalml::Cli::Command

Instance Method Details

#run(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/chemicalml/cli/inspect_command.rb', line 8

def run(options)
  path = options[:file]
  unless path
    logger.error 'inspect requires a <file> argument'
    return 2
  end

  doc = Chemicalml.parse(File.read(path), schema: :schema3)
  print_tree(doc, 0)
  0
rescue ArgumentError, Lutaml::Model::InvalidFormatError => e
  logger.error "FAIL: #{e.message}"
  2
end