Module: Laser::Cutter::CLI

Extended by:
Dry::CLI::Registry
Defined in:
lib/laser/cutter/cli.rb,
lib/laser/cutter/cli/help.rb,
lib/laser/cutter/cli/command.rb,
lib/laser/cutter/cli/version.rb,
lib/laser/cutter/cli/examples.rb,
lib/laser/cutter/cli/generate.rb,
lib/laser/cutter/cli/completion.rb,
lib/laser/cutter/cli/page_sizes.rb,
lib/laser/cutter/cli/config_file.rb

Overview

Every command the executable answers to.

Defined Under Namespace

Classes: Command, Completion, ConfigFile, Examples, Generate, Help, PageSizes, Version

Constant Summary collapse

PROGRAM =

The name of the executable, as help and completion print it.

'laser-cutter'
HELP_WIDTH =

Help and boxes are never wider than this, however wide the terminal is.

100
DEFAULT_COLUMNS =

Columns assumed when there is no terminal, or it reports none.

90

Class Method Summary collapse

Class Method Details

.console(out:, err:) ⇒ Dry::CLI::UI::Console

Boxes as wide as help. dry-cli-ui assumes 80 columns on a stream that is not a tty, such as a pipe, so it is told the terminal's width.

Parameters:

  • out (IO) —

    where info and success boxes go

  • err (IO) —

    where error boxes go

Returns:

  • (Dry::CLI::UI::Console)


34
35
36
# File 'lib/laser/cutter/cli.rb', line 34

def self.console(out:, err:)
  Dry::CLI::UI::Console.new(out: out, err: err, width: Dry::CLI::Help::Terminal.width, box_width: help_width)
end

.help_width(columns = Dry::CLI::Help::Terminal.width) ⇒ Integer

COLUMNS wins over the console, as it does for dry-cli-help, so a test can pin the width.

Parameters:

  • columns (Integer, nil) (defaults to: Dry::CLI::Help::Terminal.width) —

    the width of the terminal; nil or 0 for DEFAULT_COLUMNS

Returns:

  • (Integer) —

    columns help wraps at, and a box takes: the terminal's less 6, capped at HELP_WIDTH



23
24
25
26
# File 'lib/laser/cutter/cli.rb', line 23

def self.help_width(columns = Dry::CLI::Help::Terminal.width)
  columns = DEFAULT_COLUMNS unless columns&.positive?
  [columns - 6, HELP_WIDTH].min
end