Class: DocToDash::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_to_dash/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



9
10
11
12
13
14
15
16
17
# File 'lib/doc_to_dash/cli.rb', line 9

def initialize
  @opts = Trollop::options do
    banner DocToDash::CLI.banner_data
    opt :icon,    "Docset icon which will display in Dash.",            :type => :string
    opt :name,    "Docset name which will display in Dash.",            :type => :string
    opt :output,  "Docset Output Path where the docset will be saved.", :type => :string
    opt :parser,  "Docset parser to use.",                              :type => :string
  end
end

Class Method Details



35
36
37
38
39
40
41
42
43
44
# File 'lib/doc_to_dash/cli.rb', line 35

def self.banner_data
  <<-EOS
DocToDash converts RDoc and YARD documentation files to Dash format.

Usage:
    doc_to_dash [options] <docset_path>

where [options] are:
  EOS
end

.runObject



5
6
7
# File 'lib/doc_to_dash/cli.rb', line 5

def self.run
  self.new.run
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/doc_to_dash/cli.rb', line 19

def run
  if ARGV.count == 0
    puts "Error.  Please run doc_to_dash again with the --help switch.  Missing <docset_path>."
    return false
  end

  docset_options = {}
  docset_options[:doc_input_path]     = ARGV.first
  docset_options[:icon_path]          = @opts[:icon]                        unless @opts[:icon].nil?
  docset_options[:docset_name]        = @opts[:name]                        unless @opts[:name].nil?
  docset_options[:docset_output_path] = @opts[:output]                      unless @opts[:output].nil?
  docset_options[:parser]             = DocToDash.const_get(@opts[:parser]) unless @opts[:parser].nil?

  DocToDash::DocsetGenerator.new(docset_options).run
end