Module: Hamdown::Cli

Defined in:
lib/hamdown/cli.rb

Overview

CLI module it takes args with file path and return text to STDOUT

Class Method Summary collapse

Class Method Details

.perform(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/hamdown/cli.rb', line 5

def self.perform(args)
  file_path = args[0]
  if file_path.nil? || file_path.size == 0
    puts 'Error: No file.'
    puts 'Use it like: "bin/hamdown path_to/file.hd > output.html"'
    return nil
  end

  content = File.open(file_path, 'r').read
  output = Engine.perform(content)
  puts output
end