Sha256: bba708abbf7b03aea51c7f6cd088d77a5ae3393eb028d2b78d1758ecfaa16178

Contents?: true

Size: 859 Bytes

Versions: 1

Compression:

Stored size: 859 Bytes

Contents

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

$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))

require "mdcat"
require "tty-markdown"

BANNER = %q(
          _         _
 _ __  __| |__ __ _| |_
| '  \/ _` / _/ _` |  _|
|_|_|_\__,_\__\__,_|\__|
)

def help
  puts %(
#{BANNER}
version (#{Mdcat::VERSION})

USAGE
  mdcat <file>

COMMANDS
  mdcat -h, help               show this help message

EXAMPLES
  `mdcat README.md`            for printing to stdout
  `mdcat README.md | less`     for paging long documents
  )
end

# commands
if ARGV[0] == "-h" || ARGV[0] == "help"
  help
  exit(0)
end

# validations
file_path = ARGV[0]
if file_path.nil?
  help
  exit(1)
end

file = File.expand_path(file_path)
unless File.exist?(file)
  help
  puts "File not found: #{file}"
  exit(1)
end

# proessing file and output
puts TTY::Markdown.parse_file(file)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mdcat-0.3.0 bin/mdcat