Class: Webgen::CLI::ShowDependenciesCommand

Inherits:
CmdParse::Command
  • Object
show all
Defined in:
lib/webgen/cli/commands/show_dependencies.rb

Overview

The CLI command for showing dependencies (tracked items) of paths.

Instance Method Summary collapse

Constructor Details

#initializeShowDependenciesCommand

:nodoc:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/webgen/cli/commands/show_dependencies.rb', line 11

def initialize # :nodoc:
  super('deps', takes_commands: false)
  short_desc('Show dependencies for all paths')
  long_desc(<<DESC)
Shows the dependencies (i.e. tracked items) for each path. This is only useful
after webgen has generated the website at least once so that this information
is available.

If an argument is given, only those paths that have the argument in their name
are displayed with their dependencies.

Hint: The global verbosity option enables additional output.
DESC
end

Instance Method Details

#execute(selector = nil) ⇒ Object

:nodoc:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/webgen/cli/commands/show_dependencies.rb', line 26

def execute(selector = nil) # :nodoc:
  data = command_parser.website.ext.item_tracker.cached_items(command_parser.verbose)
  if data.empty?
    puts "No data available, you need to generate the website first!"
    return
  end

  data.select! {|alcn, _| alcn.include?(selector) } if selector
  data.sort.each do |alcn, items|
    if items.length > 0 || command_parser.verbose
      puts("#{Utils.light(Utils.blue(alcn))}: ")
      items.each {|d| puts("  #{[d].flatten.join("\n    ")}")}
    end
  end
end