File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,17 +72,21 @@ def main # to separate binding
7272 options = { }
7373 options [ :erb ] = File . expand_path ( '../../templates/template.html.erb' , __FILE__ )
7474 option_parser = OptionParser . new do |opts |
75- opts . on ( "-i INPUT" ) do |input |
75+ opts . on ( "-i INPUT" , "Input form the file" ) do |input |
7676 options [ :input ] = input
7777 end
78- opts . on ( "-e ERB" ) do |erb |
78+ opts . on ( "-e ERB" , "Specify template file" ) do |erb |
7979 options [ :erb ] = erb
8080 end
81- opts . on ( "-o OUTPUT" ) do |output |
81+ opts . on ( "-o OUTPUT" , "Output html to OUTPUT" ) do |output |
8282 options [ :output ] = output
8383 end
84+ opts . on ( "-h" , "--help" , "Prints this help" ) do
85+ puts opts
86+ exit
87+ end
8488 opts . on_tail ( "--version" , "Show version" ) do
85- puts "0.1.0"
89+ puts Rubydown :: VERSION
8690 exit
8791 end
8892 end
@@ -93,6 +97,15 @@ def main # to separate binding
9397 # puts options[:erb]
9498 # puts options[:output]
9599
100+ case options [ :input ]
101+ when /\. md\z /i
102+ options [ :output ] ||= options [ :input ] . sub ( /\. md\z /i , '.html' )
103+ when /./
104+ abort ( "Input file must be markdown (*.md)" )
105+ else
106+ abort ( option_parser . help )
107+ end
108+
96109 doc = EvalDoc . new ( File . read ( options [ :input ] , encoding : 'utf-8' ) ) # using in ERB
97110 File . write ( options [ :output ] , ERB . new ( File . read ( options [ :erb ] ) ) . result ( binding ) )
98111# puts ERB.new(File.read(options[:erb])).result(binding)
You can’t perform that action at this time.
0 commit comments