Class: Webgen::CLI::ShowTreeCommand

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

Overview

The CLI command for showing the node tree.

Instance Method Summary collapse

Constructor Details

#initializeShowTreeCommand

:nodoc:



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
38
39
40
41
42
43
44
45
# File 'lib/webgen/cli/commands/show_tree.rb', line 11

def initialize # :nodoc:
  super('tree', takes_commands: false)
  short_desc('Show the node tree')
  long_desc(<<DESC)
Shows the internal representation of all destination paths that have been created
from the source paths. Additionally, the meta information associated with each
node can be shown as well.

This command can be used before or after the website has been generated. Note,
however, that nodes that are created during generation like fragment nodes can
only be shown if the website has been generated.

Due to the way webgen works this command may take some time before actually
showing the tree because it has to be built first.

If an argument is given, only those nodes that have the argument in their LCN
are displayed.

Hint: The global verbosity option enables additional output.
DESC
  options do |opts|
    opts.on("-a", "--alcn", "Use ALCN insted of LCN for paths") do |v|
      @use_alcn = true
    end
    opts.on("-f", "--[no-]fragments", "Show fragment nodes (default: no)") do |v|
      @show_fragments = v
    end
    opts.on("-m", "--[no-]meta-info", "Show meta information (default: no)") do |v|
      @meta_info = v
    end
  end
  @meta_info = false
  @use_alcn = false
  @show_fragments = false
end

Instance Method Details

#execute(selector = nil) ⇒ Object

:nodoc:



47
48
49
50
51
# File 'lib/webgen/cli/commands/show_tree.rb', line 47

def execute(selector = nil) # :nodoc:
  command_parser.website.ext.path_handler.populate_tree
  data = collect_data(command_parser.website.tree.dummy_root.children, selector)
  print_tree(data, selector)
end