Class: Metado::CLI

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

Class Method Summary collapse

Class Method Details

.startObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/metado/cli.rb', line 8

def self.start
  unless (dir = ARGV.first)
    puts "Usage: metado SOURCE_DIR"
    exit 1
  end

  result = Dir["#{dir}/**/*.{c,hs,js,m,md,mm,py,rb,sh,swift}"].flat_map do |file|
    next unless File.file?(file)

    Parser::File.comments(file).map(&Parser::Metado.method(:parse)).flatten.map(&:to_h)
  end.compact

  puts JSON.generate result
end