Cuprum::Cli

A command-line utility powered by Cuprum that provides tools and utilities for defining command-line tools.

Integrations

Cuprum::Cli integrates with third-party tools to call commands from the command line.

Integrations are not loaded or auto-loadable by default; to use integration code, you must manually require the integration.

Async

Cuprum::Cli defines an optional integration with the Async gem to parallelize some commands.

Back to Top

Built-In Commands

Cuprum::Cli uses the Async gem to parallelize the following commands.

Back to Top

RSpec Each Command

As the RSpec Each Command, but with concurrent execution for the individual spec files. It supports the following additional options:

:max_jobs
The maximum number of concurrent jobs. Defaults to the value of ENV['ASYNC_CONCURRENT_TASKS'], or 8.

Important Note: Applications that rely on external resources such as databases should be cautious when running tests in parallel. Best practice is to provide an isolated environment for each test run.

Thor

Cuprum::Cli defines an integration with the Thor toolkit.

Registering Commands

To use the Thor integration, open or create a file with .thor extname to define your Thor commands and create an instance of Cuprum::Cli::Integrations::Thor::Registry.

# In tasks.thor:
require 'cuprum/cli/integrations/thor/registry'

registry = Cuprum::Cli::Integrations::Thor::Registry.new

To register a command, use the registry.register(command) method.

registry.register Cuprum::Cli::Commands::Ci::RSpecCommand

This will register the command for Thor using its default name, description and options.

% bundle exec thor list
ci
--
thor ci:rspec ...FILE_PATTERNS       # Runs an RSpec command.

Back to Top

Naming Commands

You can customize the name or description of the command by passing :full_name or :description values to #register.

registry.register Cuprum::Cli::Commands::Ci::RSpecCommand,
  full_name: 'tests:rspec:all'

Back to Top

Command Configuration

If you pass :arguments or :options to #register, those parameters will be added to any parameters from the command line when the command is called. This allows you to define multiple variants of a command with pre-defined configuration.

registry.register Cuprum::Cli::Commands::Ci::RSpecCommand
registry.register Cuprum::Cli::Commands::Ci::RSpecCommand,
  full_name:   'ci:rspec:sinatra4',
  description: 'Runs the RSpec tests against Sinatra 4.X',
  options:     { gemfile: 'gemfiles/sinatra_4.gemfile' }

Back to Top


Back to Documentation