Class: Webgen::CLI::CreateWebsiteCommand
- Inherits:
-
CmdParse::Command
- Object
- CmdParse::Command
- Webgen::CLI::CreateWebsiteCommand
- Defined in:
- lib/webgen/cli/commands/create_website.rb
Overview
The CLI command for creating a webgen website.
Instance Method Summary collapse
-
#execute(dir) ⇒ Object
:nodoc:.
-
#help ⇒ Object
:nodoc:.
-
#initialize ⇒ CreateWebsiteCommand
constructor
:nodoc:.
Constructor Details
#initialize ⇒ CreateWebsiteCommand
:nodoc:
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/webgen/cli/commands/create_website.rb', line 12 def initialize # :nodoc: super('website', takes_commands: false) short_desc('Create a basic webgen website') long_desc(<<DESC) Creates a webgen website at the specified directory. If the --template option is not used, a basic website is created. Otherwise the template defines the content of website. Hint: If the global verbosity option is enabled, the created files are displayed. DESC @template = nil .on('-t', '--template TEMPLATE', String, "A website template (optional)") do |val| @template = val end end |
Instance Method Details
#execute(dir) ⇒ Object
:nodoc:
43 44 45 46 47 48 49 50 51 |
# File 'lib/webgen/cli/commands/create_website.rb', line 43 def execute(dir) # :nodoc: Webgen::Website.new(dir, Webgen::CLI::Logger.new) do |website| website.logger.verbose = command_parser.verbose website.config['website.tmpdir'] = Dir.tmpdir end.execute_task(:create_website, @template) puts "Created a new webgen website in <#{dir}>" + (@template ? " using the '#{@template}' template" : '') rescue Webgen::Task::CreateWebsite::Error => e puts "An error occured while creating the website: #{e.}" end |
#help ⇒ Object
:nodoc:
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/webgen/cli/commands/create_website.rb', line 30 def help #:nodoc: help_output = super templates = command_parser.website.ext.task.data(:create_website)[:templates].keys.sort help_output << "Available templates:\n" output = if templates.empty? "No templates available" else templates.join(', ') end help_output << Utils.format(output, command_parser.help_line_width - command_parser.help_indent, command_parser.help_indent, true).join("\n") end |