diff --git a/lib/rdf/cli.rb b/lib/rdf/cli.rb index ad9514d7..defaf7d8 100644 --- a/lib/rdf/cli.rb +++ b/lib/rdf/cli.rb @@ -256,8 +256,7 @@ def to_hash lambda: ->(argv, opts) do writer_class = RDF::Writer.for(opts[:output_format]) || RDF::NTriples::Writer out = opts[:output] - opts = opts.merge(prefixes: {}) - writer_opts = opts.merge(standard_prefixes: true) + writer_opts = {prefixes: {}, standard_prefixes: true}.merge(opts) writer_class.new(out, **writer_opts) do |writer| writer << repository end @@ -536,6 +535,8 @@ def self.exec(args, output: $stdout, option_parser: nil, messages: {}, **options count = 0 self.parse(args, **options) do |reader| reader.each_statement {|st| @repository << st} + # Remember prefixes from reading + options[:prefixes] ||= reader.prefixes end secs = Time.new - start options[:logger].info "Parsed #{repository.count} statements with #{@readers.join(', ')} in #{secs} seconds @ #{count/secs} statements/second."