Sha256: 1b1401981b683c391b4aff66f58ae1078fb13fdb348eed907414da32543691cb

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

#!/usr/bin/env ruby

# for dev purposes
require 'bundler/setup' if ENV['HONEY_FORMAT_GEM_DEV']
require 'honey_format'

require 'honey_format/cli/cli'

cli = HoneyFormat::CLI.new
options = cli.options

input_path = options[:input_path] || raise(ArgumentError, 'input path required')
csv_input = File.read(input_path)
csv = HoneyFormat::CSV.new(
  csv_input,
  delimiter: options[:delimiter],
  type_map: options[:type_map],
  skip_lines: options[:skip_lines]
)

csv_part = if options[:header_only]
             csv.header
           elsif options[:rows_only]
             csv.rows
           else
             csv
           end

csv_string = csv_part.to_csv(columns: options[:columns])
if path = options[:output_path]
  File.write(path, csv_string)
else
  puts csv_string
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
honey_format-0.16.0 exe/honey_format