Module: Nanoc::CLI

Defined in:
lib/nanoc/cli.rb,
lib/nanoc/cli/cleaning_stream.rb,
lib/nanoc/cli/command_runner.rb,
lib/nanoc/cli/stream_cleaners.rb,
lib/nanoc/cli/ansi_string_colorizer.rb,
lib/nanoc/cli/logger.rb,
lib/nanoc/cli/error_handler.rb

Defined Under Namespace

Modules: ANSIStringColorizer, Commands, StreamCleaners Classes: CleaningStream, CommandRunner, ErrorHandler, Logger

Constant Summary

Command =
Deprecated.

Use CommandRunner instead

CommandRunner

Class Method Summary (collapse)

Class Method Details

+ (void) add_command(cmd)

This method returns an undefined value.

Adds the given command to the collection of available commands.

Parameters:

  • cmd (Cri::Command)

    The command to add



72
73
74
# File 'lib/nanoc/cli.rb', line 72

def self.add_command(cmd)
  root_command.add_command(cmd)
end

+ (void) after_setup(&block)

This method returns an undefined value.

Schedules the given block to be executed after the CLI has been set up.



79
80
81
82
# File 'lib/nanoc/cli.rb', line 79

def self.after_setup(&block)
  # TODO: decide what should happen if the CLI is already set up
  add_after_setup_proc(block)
end

+ (void) debug=(boolean)

This method returns an undefined value.

Parameters:

  • boolean (Boolean)

    true if debug output should be enabled, false if it should not

Since:

  • 3.2.0



46
47
48
# File 'lib/nanoc/cli.rb', line 46

def self.debug=(boolean)
  @debug = boolean
end

+ (Boolean) debug?

Returns true if debug output is enabled, false if not

Returns:

  • (Boolean)

    true if debug output is enabled, false if not

Since:

  • 3.2.0



36
37
38
# File 'lib/nanoc/cli.rb', line 36

def self.debug?
  @debug || false
end

+ (Cri::Command) root_command

Returns The root command, i.e. the command-line tool itself

Returns:

  • (Cri::Command)

    The root command, i.e. the command-line tool itself



63
64
65
# File 'lib/nanoc/cli.rb', line 63

def self.root_command
  @root_command
end

+ (void) run(args)

This method returns an undefined value.

Invokes the nanoc command-line tool with the given arguments.

Parameters:

  • args (Array<String>)

    An array of command-line arguments



55
56
57
58
59
60
# File 'lib/nanoc/cli.rb', line 55

def self.run(args)
  Nanoc::CLI::ErrorHandler.handle_while do
    setup
    root_command.run(args)
  end
end