Sha256: bcb8fcddfc133544ea68b2c1d37ac226c56f4b4803abeeff15b71c25eb450ae5

Contents?: true

Size: 787 Bytes

Versions: 4

Compression:

Stored size: 787 Bytes

Contents

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

require_relative '../lib/tabled'
require_relative '../lib/parsers/csv_parser'
require 'dry/cli'
require 'pathname'

module TabledCli
  module CLI
    module Commands
      extend Dry::CLI::Registry

      class Print < Dry::CLI::Command
        desc 'Printing CSV to console'

        argument :input, desc: 'Input file to print'

        def call(input: nil, **)
          return p 'File must be provided' if input.nil?
          return p 'File doesn\'t exist' unless File.exist?(Pathname.new(input))

          Tabled.new(Tabled::CSVParser.parse(Pathname.new(input))).print_to_console
        end
      end

      register 'print', Print, aliases: ['p', '-p', '--print']
    end
  end
end

Dry::CLI.new(TabledCli::CLI::Commands).call

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tabled-1.0.0 bin/tabled
tabled-0.0.6 bin/tabled
tabled-0.0.5 bin/tabled
tabled-0.0.4 bin/tabled