Cuprum::Cli

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

Class: Cuprum::Cli::Commands::File::NewCommand

Parent Namespace
Cuprum::Cli::Commands::File
Inherited Classes
Cuprum::Cli::Command > Cuprum::Command > Object
Included Modules
Cuprum::Cli::Options::Quiet, Cuprum::Cli::Options::Verbose
Defined In
lib/cuprum/cli/commands/file/new_command.rb

Table Of Contents

Overview

Command for generating a templated file or files.

Back To Top

Constants

FULL_NAME_FORMAT

= /\A[a-z_]+(:[a-z_]+)*\z/

Inherited From
Cuprum::Cli::Metadata

Format used to validate command names.

Back To Top

Class Methods

.argument(name, default: nil, description: nil, required: false, type: :string, variadic: false, **options) => Object

Inherited From
Cuprum::Cli::Command

Defines an argument for the command class.

Parameters

Options Hash (options)

Raises

.argument_value(value) => void

Inherited From
Cuprum::Cli::Arguments::ClassMethods

Appends a predefined argument value for the command.

Parameters

Returns

.argument_values => Array<Object>

Inherited From
Cuprum::Cli::Arguments::ClassMethods

Returns

.arguments() => Array<Cuprum::Cli::Argument>
.arguments(name, default: nil, description: nil, required: false, type: :string, **options) => Object

Inherited From
Cuprum::Cli::Arguments::ClassMethods

Overloads

.arguments() => Array<Cuprum::Cli::Argument>

The defined arguments for the command class.

Returns
.arguments(name, default: nil, description: nil, required: false, type: :string, **options) => Object

Defines a variadic argument for the command class.

Parameters
  • name (String, Symbol) — the name of the argument.
  • default (Object, Proc) — the default value for the argument. If given and the value of the argument is nil, sets the argument value to the default value.
  • description (String) — a short, human-readable description of the argument.
  • required (true, false) — if true, raises an exception if the argument is not provided to the command.
  • type (Class, String, Symbol) — the expected type of the argument value as a Class or class name. If given, raises an exception if the argument value is not an instance of the type. Defaults to :string.
  • options (Hash) — additional options for defining the argument.
Options Hash (options)
  • define_method (true, false) — if true, defines a reader method for the argument. Defaults to false for boolean arguments and true for all other arguments.
  • define_predicate (true, false) — if true, defines a predicate method for the argument, which returns true if the argument is not nil and not empty. Defaults to true for boolean arguments and false for all other arguments.

.dependency(dependency_name, **) => Object

Inherited From
Cuprum::Cli::Command

Raises

.option(option_name, **) => Object

Inherited From
Cuprum::Cli::Command

Raises

.option_value(option, value) => void

Inherited From
Cuprum::Cli::Options::ClassMethods

Assigns a predefined option value for the command.

Parameters

Returns

.option_values => Hash{Symbol => Object}

Inherited From
Cuprum::Cli::Options::ClassMethods

Returns

.options => Hash{Symbol => Cuprum::Cli::Option}

Inherited From
Cuprum::Cli::Options::ClassMethods

The defined options, including options defined on ancestor classes.

Returns

.resolve_arguments(*values) => Array

Inherited From
Cuprum::Cli::Arguments::ClassMethods

Validates the given argument values against the defined class arguments.

Also applies any default values from the defined arguments.

Parameters

Returns

Raises

.resolve_options(**values) => Hash

Inherited From
Cuprum::Cli::Options::ClassMethods

Validates the given option values against the defined class options.

Also applies any default values from the defined options.

Parameters

Returns

Raises

Back To Top

Constructor

#initialize(**) => Command

Inherited From
Cuprum::Cli::Command

Returns

Back To Top

Instance Methods

#call(*arguments, **options) => Cuprum::Result
#call(resolved_arguments:, resolved_options:) => Cuprum::Result

Inherited From
Cuprum::Cli::Command

Overloads

#call(*arguments, **options) => Cuprum::Result

Resolves the parameters and calls the command.

Parameters
  • arguments (Array) — arguments passed to the command.
  • options (Hash) — options passed to the command.
Returns
  • (Cuprum::Result) — the command result.
Raises
#call(resolved_arguments:, resolved_options:) => Cuprum::Result

Calls the command with the given arguments and options.

This variant assumes that the arguments and options have already been parsed and validated against the command’s expected parameters.

Parameters
  • resolved_arguments (Hash) — the arguments passed to the command, formatted as an Hash with the matching argument name as key and the argument value as the corresponding value.
  • resolved_options (Hash) — the options passed to the command.
Returns
  • (Cuprum::Result) — the command result.

#say(message, newline: true, quiet: false, verbose: false, **options) => nil

Inherited From
Cuprum::Cli::Options::Verbose

Prints a message to the output stream.

Parameters

Options Hash (options)

Returns

Back To Top


Back to Documentation | Reference | Cuprum | Cuprum::Cli | Cuprum::Cli::Commands | Cuprum::Cli::Commands::File