Module: Webgen::CLI

Defined in:
lib/webgen/cli.rb,
lib/webgen/cli/utils.rb,
lib/webgen/cli/logger.rb,
lib/webgen/cli/commands/show.rb,
lib/webgen/cli/commands/create.rb,
lib/webgen/cli/commands/install.rb,
lib/webgen/cli/commands/generate.rb,
lib/webgen/cli/commands/show_tree.rb,
lib/webgen/cli/commands/show_config.rb,
lib/webgen/cli/commands/show_bundles.rb,
lib/webgen/cli/commands/create_bundle.rb,
lib/webgen/cli/commands/create_website.rb,
lib/webgen/cli/commands/show_extensions.rb,
lib/webgen/cli/commands/show_dependencies.rb

Overview

Namespace for all classes that act as CLI commands.

Implementing a CLI command

A CLI command is an extension that can be invoked from the webgen CLI and thus needs to be derived from CmdParse::Command. For detailed information on this class and the whole cmdparse package have a look at http://cmdparse.gettalong.org!

Sample CLI command extension

Here is a sample CLI command extension:

class SampleCommand < CmdParse::Command

def initialize
  super('sample', takes_commands: false)
  short_desc("This sample command just outputs its parameters")
  description("Uses the global verbosity level and outputs additional information when " +
                "the level is set to verbose!")
  @username = nil
  options.on('-u', '--user USER', String, 'Specify an additional user name to output') do |username|
    @username = username
  end
end

def execute(required, *optional)
  puts "Command line arguments:"
  ([required] + optional).each {|arg| puts arg}
  if command_parser.log_level <= 1
    puts "Some debug information here"
  end
  puts "The entered username: #{@username}" if @username
end

end

website.ext.cli.add_command(SampleCommand.new)

The Webgen::CLI::Utils module provides some useful methods for outputting formatted or highlighted text.

Defined Under Namespace

Modules: Utils Classes: CommandParser, CreateBundleCommand, CreateCommand, CreateWebsiteCommand, GenerateCommand, InstallCommand, Logger, ShowBundlesCommand, ShowCommand, ShowConfigCommand, ShowDependenciesCommand, ShowExtensionsCommand, ShowTreeCommand