Class: Webgen::CLI::ShowConfigCommand

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

Overview

The CLI command for showing all available options.

Instance Method Summary collapse

Constructor Details

#initializeShowConfigCommand

: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_config.rb', line 11

def initialize # :nodoc:
  super('config', takes_commands: false)
  short_desc('Show available configuration options')
  long_desc(<<DESC)
Shows all available configuration options. The option name and default value as
well as the currently used value are displayed.

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

The global verbosity flag enables all optional display parts.

Hint: A debug message will appear at the top of the output if this command is run
in the context of a website, there are unknown configuration options in the
configuration file and the log level is set to debug.
DESC
  options do |opts|
    opts.on("-m", "--modified", "Show modified configuration options only") do |v|
      @modified = true
    end
    opts.on("-d", "--[no-]descriptions", "Show descriptions") do |d|
      @show_description = d
    end
    opts.on("-s", "--[no-]syntax", "Show the syntax") do |s|
      @show_syntax = s
    end
    opts.on("-e", "--[no-]example", "Show usage examples") do |e|
      @show_examples = e
    end
  end
  @modified = false
  @show_description = false
  @show_syntax = false
  @show_examples = false
end

Instance Method Details

#execute(selector = '') ⇒ Object

:nodoc:



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/webgen/cli/commands/show_config.rb', line 47

def execute(selector = '') # :nodoc:
  @show_description = @show_syntax = @show_examples = true if command_parser.verbose

  config = command_parser.website.config
  descriptions = command_parser.website.ext.bundle_infos.options
  config.options.select do |n, d|
    n.include?(selector) && (!@modified || config[n] != d.default)
  end.sort.each do |name, data|
    format_config_option(name, data, config[name], descriptions[name])
  end
end