rabbitmq-server/deps/rabbitmq_cli
Gerhard Lazu 240c7c0862 Merge pull request #156 from rabbitmq/rabbitmq-cli-153
Load .ez plugins without version
2016-12-14 17:00:40 +00:00
..
config script name is overridable via argument 2016-11-08 14:21:31 +00:00
include Removed rabbit_cli.hrl file. 2016-02-03 10:03:50 -05:00
lib Merge pull request #156 from rabbitmq/rabbitmq-cli-153 2016-12-14 17:00:40 +00:00
test Merge pull request #156 from rabbitmq/rabbitmq-cli-153 2016-12-14 17:00:40 +00:00
.gitignore Copy CTL modules to /ebin to be included in ERL_LIBS 2016-11-17 10:50:15 +00: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 typo in tutorial file name 2016-11-30 17:35:18 +01:00
CONTRIBUTING.md Add CONTRIBUTING.md, move Running Tests to it 2016-12-14 14:27:53 +03:00
DESIGN.md Formatting and corrections in docs 2016-12-13 15:00:12 +00:00
Makefile Sort commands when printing help 2016-12-07 16:21:10 +00:00
README.md Add CONTRIBUTING.md, move Running Tests to it 2016-12-14 14:27:53 +03:00
bash-complete Rename auto complete option for consistency 2016-08-10 18:19:06 +01:00
complete Command auto completion 2016-07-28 17:46:37 +01:00
erlang.mk Update erlang.mk 2016-11-22 16:18:34 +00:00
mix.exs Test commands suggestions 2016-12-06 12:19:25 +00:00
rabbitmq-components.mk Update rabbitmq-components.mk 2016-12-08 19:16:48 +01:00
zsh-complete Rename auto complete option for consistency 2016-08-10 18:19:06 +01:00

README.md

RabbitMQ CLI Tools

This is the next generation implementation of rabbitmqctl and other RabbitMQ CLI tools.

This project is a work in progress and targets RabbitMQ 3.7.0 (currently the master branch). For production use, go with the rabbitmqctl distributed with the RabbitMQ version you use.

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

This version of CLI tools targets RabbitMQ master (future 3.7.0). Some operations (for example, the list_* ones) will not work with earlier server releases.

Building

Requirements

Building this project requires Elixir 1.3.1 or greater.

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

Building Standalone Executables

This repo produce a rabbitmqctl executable which can be used as different tools by copying or symlinking it with different names.

Currently rabbitmq-plugins and rabbitmq-diagnostics tools are supported.

To generate the executable, run

make

Usage

rabbitmqctl

rabbitmqctl [-n node] [-t timeout] [-q] {command} [command options...]

See the rabbitmqctl man page for a full list of options.

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 is also a number of optional callbacks:

  • switches, which returns command specific switches.
  • aliases, which returns a list of command alianses (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) with commands.

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 simple examples.

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

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