Sha256: a7d0a7d9bf45b0a76d3b6c8fc31f89637daae48d6e321b9ac914a783e70fffe7

Contents?: true

Size: 806 Bytes

Versions: 2

Compression:

Stored size: 806 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# 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

2 entries across 2 versions & 1 rubygems

Version Path
honey_format-0.18.0 exe/honey_format
honey_format-0.17.0 exe/honey_format