Class: Lm2doc::Cli
- Inherits:
-
Object
- Object
- Lm2doc::Cli
- Defined in:
- lib/lm2doc/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#inputs ⇒ Object
Returns the value of attribute inputs.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv) ⇒ Cli
constructor
A new instance of Cli.
- #parse_argv ⇒ Object
- #perfrom_source(source_file) ⇒ Object
- #theme ⇒ Object
Constructor Details
#initialize(argv) ⇒ Cli
Returns a new instance of Cli.
8 9 10 |
# File 'lib/lm2doc/cli.rb', line 8 def initialize(argv) self.argv = argv end |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
6 7 8 |
# File 'lib/lm2doc/cli.rb', line 6 def argv @argv end |
#inputs ⇒ Object
Returns the value of attribute inputs.
6 7 8 |
# File 'lib/lm2doc/cli.rb', line 6 def inputs @inputs end |
#output ⇒ Object
Returns the value of attribute output.
6 7 8 |
# File 'lib/lm2doc/cli.rb', line 6 def output @output end |
Instance Method Details
#execute ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/lm2doc/cli.rb', line 41 def execute self.parse_argv self.inputs.each do |input| perfrom_source(input) end end |
#parse_argv ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lm2doc/cli.rb', line 16 def parse_argv self.inputs = [] opts = OptionParser.new(self.argv.dup) do |opts| opts. = "lm2doc is a convertor for lightweight markup language to pretty html document." opts.separator "" opts.separator "Usage:" opts.separator " lm2doc [OPTION]...[-i] FILE" opts.separator "" opts.separator "Options:" opts.on("-v", "--version", "show the version of lm2doc") { puts Lm2doc::VERSION; exit } opts.on("-i", "--in FILE", "input path") {|v| self.inputs = [ v ] } # opts.on("-o", "--out DIR|FILE", "output path") {|v| self.output = v } end others = opts.parse! self.inputs = others if self.inputs.length != 1 puts opts.help() exit end end |