Class: Bibliothecary::CLI

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/bibliothecary/cli.rb

Instance Method Summary collapse

Instance Method Details

#runObject



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
# File 'lib/bibliothecary/cli.rb', line 9

def run
  program :name, 'Bibliothecary'
  program :version, Bibliothecary::VERSION
  program :description, 'Parse dependency information from a file or folder of code'

  command(:list) do |c|
    c.syntax = 'bibliothecary list'
    c.description = 'List dependencies'
    c.option("--path FILENAME", String, "Path to file/folder to analyse")
    c.action do |_args, options|
      options.default path: './'
      output = Bibliothecary.analyse(options.path)
      output.each do |manifest|
        puts "#{manifest[:path]} (#{manifest[:platform]})"
        manifest[:dependencies].group_by{|d| d[:type] }.each do |type, deps|
          puts "  #{type}"
          deps.each do |dep|
            puts "    #{dep[:name]} #{dep[:requirement]}"
          end
          puts
        end
        puts
      end
    end
  end

  run!
end