rabbitmq-server/deps/rabbitmq_cli
Josh Soref ce893da54c spelling: already 2019-02-13 00:17:15 -05:00
..
config Do not crash command loading if unable to read enabled plugins file. 2017-07-24 17:28:12 +01:00
include Removed rabbit_cli.hrl file. 2016-02-03 10:03:50 -05:00
lib A typo 2019-02-21 21:02:52 +03:00
test spelling: already 2019-02-13 00:17:15 -05:00
.gitignore Ignore ./log 2017-02-02 00:14:21 +03:00
CODE_OF_CONDUCT.md Copy Code of Conduct document from rabbitmq-server 2016-12-14 14:27:21 +03:00
COMMAND_TUTORIAL.md Fix tutorial module to make it work. 2018-03-07 15:20:41 +00:00
CONTRIBUTING.md Update CONTRIBUTING.md 2017-03-09 14:52:18 +03:00
DESIGN.md Fixed typos 2019-02-01 22:17:45 +01:00
Makefile Add `gmake format` 2019-01-30 22:15:28 +03:00
README.md A typo 2019-01-29 02:59:01 +03:00
erlang.mk spelling: abstract 2019-02-13 00:16:51 -05:00
mix.exs Use elixir internal distance function instead of a library for command similarity comparison. 2019-02-12 15:22:02 -05:00
rabbitmq-components.mk Update rabbitmq-components.mk 2019-02-12 23:23:49 +03:00

README.md

RabbitMQ CLI Tools

This repository contains RabbitMQ CLI tools (rabbitmqctl and others).

This generation of CLI tools first shipped with RabbitMQ 3.7.0.

Goals

Team RabbitMQ wanted a set of tools that

  • Was extensible from/with plugins
  • Supported pluggable output formats (in particular machine-friendly ones)
  • Had good test coverage
  • Wasn't as coupled to the server repository
  • Could be used as a low risk vehicle for Elixir evaluation

Supported RabbitMQ Versions

Long lived branches in this repository track the same branch in RabbitMQ core and related repositories. So master tracks master in rabbitmq-server, v3.7.x tracks branch v3.7.x in rabbitmq-server and so on.

Please use the version of CLI tools that come with the RabbitMQ distribution version installed.

Building

Requirements

Building this project requires

  • Erlang/OTP 20.3 (or later)
  • Elixir 1.7.0 (or later).

Command line tools depend on rabbitmq-common. Dependencies are being resolved by erlang.mk

Building Standalone Executables

This repo produces a rabbitmqctl executable which can be used as different tools (rabbitmq-plugins, rabbitmq-diagnostics, rabbitmq-queues) by copying or symlinking it with different names. Depending on the name, a different set of commands will be loaded and available, including for --help.

To generate the executable, run

make

Usage

rabbitmqctl

See the rabbitmqctl man page for details.

rabbitmq-plugins

See the rabbitmq-plugins man page for details.

rabbitmq-diagnostics

See rabbitmq-diagnostics --help.

Testing

See CONTRIBUTING.md.

Developing

Adding a New Command

Conventions

RabbitMQ CLI tools use module name conventions to match the command-line actions (commands) to modules. The convention is outlined in the CommandBehaviour module.

Command Module Interface

Each command module must implement the RabbitMQ.CLI.CommandBehaviour behaviour, which includes the following functions:

  • validate(args, opts), which returns either :ok or a tuple of {:validation_failure, failure_detail} where failure detail is typically one of: :too_many_args, :not_enough_args or {:bad_argument, String.t}.

  • merge_defaults(args, opts), which is used to return updated arguments and/or options.

  • run(args, opts), where the actual command is implemented. Here, args is a list of command-specific parameters and opts is a Map containing option flags.

  • usage, which returns a string describing the command, its arguments and its optional flags.

  • banner(args, opts), which returns a string to be printed before the command output.

There are also a number of optional callbacks:

  • switches, which returns command specific switches.
  • aliases, which returns a list of command aliases (if any).
  • formatter: what output formatter should be used by default.
  • usage_additional: extra values appended to the usage output to provide additional command-specific documentation.
  • scopes: what scopes this command appears in. Scopes associate tools (e.g. rabbitmqctl, rabbitmq-diagnostics, rabbitmq-queues) with commands.
  • distribution: control erlang distribution. Can be :cli (default), :none or {:fun, fun}

Tutorial

We have a tutorial that demonstrates how to add a CLI command that deletes a queue.

Examples

See lib/rabbitmq/cli/ctl/commands/status_command.ex and test/status_command_test.exs for minimalistic but not entirely trivial examples.

The project is licensed under the MPL, the same license as RabbitMQ.

(c) Pivotal Software, Inc, 2016-2019.