Class: Documentary::Cli

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

Class Method Summary collapse

Class Method Details

.run(args, out = STDOUT) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/documentary/cli.rb', line 6

def self.run(args, out=STDOUT)
  file_glob = "./**/*.rb"
  project_name = File.basename(Dir.getwd).split.each {|w| w.capitalize! }.join(' ')
  output = 'api.md'

  OptionParser.new do |opts|
    opts.on("-v", "--version", "Print version number") do
      require "documentary/version"
      out << "Documentary #{Documentary::VERSION}\n"
      exit
    end

    opts.on("-d", "--directory glob", "Set directory to search for docblocks") do |glob|
      file_glob = glob
    end

    opts.on("-p", "--project project", "Set project name") do |project|
      project_name = project
    end

    opts.on("-o", "--output output", "Set the output file") do |op|
      output = op
    end
  end.parse!

  files = Dir.glob(file_glob)
  config = {
    project: project_name,
    op: output
  }
  Documentary::Generator.new(files, config).generate
end