Commit Graph

76 Commits

Author SHA1 Message Date
Michael Klishin 17526987c6
Bump (c) year 2021-02-14 00:54:01 +03:00
dcorbacho 679ca254f3 Switch to Mozilla Public License 2.0 (MPL 2.0) 2020-07-11 19:23:07 +01:00
Jean-Sébastien Pédron 0e15591bf5 Update copyright (year 2020) 2020-03-10 15:39:56 +01:00
Michael Klishin 5b7063d07d More sensible JSON formatting for some commands
Fall back to a JSON document if command returns a bitstring
(does not do any preformatting for JSON).

Per discussion with @lukebakken

Closes #394.
2020-01-18 02:06:04 +03:00
Michael Klishin 73776fbf04 (c) bump 2019-12-29 05:50:26 +03:00
Arnaud Cogoluègnes 67a38fc2e9 Handle empty output in JSON stream
Some streaming commands with a duration argument can send the empty
string as the output (along with a finishing marker). This case was not
handled properly and would result in a stack trace when the command
returned once the duration has elapsed.
2019-09-25 16:56:47 +02:00
Michael Klishin eb6825ebbf Introduce a formatter for infinite streams of JSON objects
The input can be fed to 'jq'. There can be no JSON array
boundaries as the stream potentially never finishes.

Pairs: @dcorbacho @gerhard.
2019-09-20 19:59:32 +03:00
Michael Klishin 816bfbc50b Cosmetics
(cherry picked from commit 5e1c0841d78c8644eaea3b22837df40fd2ea1a24)

Conflicts:
	lib/rabbitmq/cli/formatters/pretty_table.ex
2019-07-08 16:18:52 +03:00
Michael Klishin 5589496678 Squash a few more compiler warnings 2019-07-08 15:55:37 +03:00
Daniil Fedotov 40194b7b8d Replace Keyword.keyword? with proplist? checks.
Keyword requires keys to be atoms, while data returned from rabbitmq
may have binary or string keys.
2019-05-23 15:48:02 +01:00
Jean-Sébastien Pédron a84853ae61 formatters/pretty_table: Adjust comment, we don't use `rabbit_pretty_stdout` anymore 2019-04-30 14:32:03 +02:00
Jean-Sébastien Pédron d0e7d15dcf formatters/pretty_table: Switch to use stdout_formatter library
... instead of the `rabbit_pretty_stdout` module.
2019-04-29 18:32:37 +02:00
Michael Klishin d2549de22e Extract several modules from RabbitMQ.CLI.Core.Helpers
In preparation to changing status command output for 3.8
2019-04-10 13:31:38 +03:00
Michael Klishin 5685e4c7c9 rabbitmq-plugins formatter: don't print legend if --silent or --quiet is used 2019-04-01 14:56:40 +03:00
Spring Operator 0a2541afd3 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# HTTP URLs that Could Not Be Fixed
These URLs were unable to be fixed. Please review them to see if they can be manually resolved.

* http://blog.listincomprehension.com/search/label/procket (200) with 1 occurrences could not be migrated:
   ([https](https://blog.listincomprehension.com/search/label/procket) result ClosedChannelException).
* http://dozzie.jarowit.net/trac/wiki/TOML (200) with 1 occurrences could not be migrated:
   ([https](https://dozzie.jarowit.net/trac/wiki/TOML) result SSLHandshakeException).
* http://dozzie.jarowit.net/trac/wiki/subproc (200) with 1 occurrences could not be migrated:
   ([https](https://dozzie.jarowit.net/trac/wiki/subproc) result SSLHandshakeException).
* http://e2project.org (200) with 1 occurrences could not be migrated:
   ([https](https://e2project.org) result AnnotatedConnectException).
* http://erlang.org/doc/reference_manual/distributed.html (200) with 1 occurrences could not be migrated:
   ([https](https://erlang.org/doc/reference_manual/distributed.html) result ConnectTimeoutException).
* http://nitrogenproject.com/ (200) with 2 occurrences could not be migrated:
   ([https](https://nitrogenproject.com/) result ConnectTimeoutException).
* http://proper.softlab.ntua.gr (200) with 1 occurrences could not be migrated:
   ([https](https://proper.softlab.ntua.gr) result SSLHandshakeException).
* http://yaws.hyber.org (200) with 1 occurrences could not be migrated:
   ([https](https://yaws.hyber.org) result AnnotatedConnectException).
* http://choven.ca (503) with 1 occurrences could not be migrated:
   ([https](https://choven.ca) result ConnectTimeoutException).

# Fixed URLs

## Fixed But Review Recommended
These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended.

* http://fixprotocol.org/ (301) with 1 occurrences migrated to:
  https://fixtrading.org ([https](https://fixprotocol.org/) result SSLHandshakeException).
* http://erldb.org (UnknownHostException) with 1 occurrences migrated to:
  https://erldb.org ([https](https://erldb.org) result UnknownHostException).
* http://elixir-lang.org/docs/stable/elixir/OptionParser.html (301) with 1 occurrences migrated to:
  https://elixir-lang.org/docs/stable/elixir/OptionParser.html ([https](https://elixir-lang.org/docs/stable/elixir/OptionParser.html) result 404).
* http://elixir-lang.org/docs/stable/elixir/Stream.html (301) with 1 occurrences migrated to:
  https://elixir-lang.org/docs/stable/elixir/Stream.html ([https](https://elixir-lang.org/docs/stable/elixir/Stream.html) result 404).

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* http://cloudi.org/ with 27 occurrences migrated to:
  https://cloudi.org/ ([https](https://cloudi.org/) result 200).
* http://elixir-lang.org with 1 occurrences migrated to:
  https://elixir-lang.org ([https](https://elixir-lang.org) result 200).
* http://elixir-lang.org/ with 2 occurrences migrated to:
  https://elixir-lang.org/ ([https](https://elixir-lang.org/) result 200).
* http://elixir-lang.org/getting-started/typespecs-and-behaviours.html with 1 occurrences migrated to:
  https://elixir-lang.org/getting-started/typespecs-and-behaviours.html ([https](https://elixir-lang.org/getting-started/typespecs-and-behaviours.html) result 200).
* http://elixir-lang.org/install.html with 1 occurrences migrated to:
  https://elixir-lang.org/install.html ([https](https://elixir-lang.org/install.html) result 200).
* http://erlware.org/ with 1 occurrences migrated to:
  https://erlware.org/ ([https](https://erlware.org/) result 200).
* http://inaka.github.io/cowboy-trails/ with 1 occurrences migrated to:
  https://inaka.github.io/cowboy-trails/ ([https](https://inaka.github.io/cowboy-trails/) result 200).
* http://ninenines.eu with 6 occurrences migrated to:
  https://ninenines.eu ([https](https://ninenines.eu) result 200).
* http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html with 1 occurrences migrated to:
  https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html ([https](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) result 200).
* http://www.actordb.com/ with 2 occurrences migrated to:
  https://www.actordb.com/ ([https](https://www.actordb.com/) result 200).
* http://www.cs.kent.ac.uk/projects/wrangler/Home.html with 1 occurrences migrated to:
  https://www.cs.kent.ac.uk/projects/wrangler/Home.html ([https](https://www.cs.kent.ac.uk/projects/wrangler/Home.html) result 200).
* http://www.rebar3.org with 1 occurrences migrated to:
  https://www.rebar3.org ([https](https://www.rebar3.org) result 200).
* http://contributor-covenant.org with 1 occurrences migrated to:
  https://contributor-covenant.org ([https](https://contributor-covenant.org) result 301).
* http://contributor-covenant.org/version/1/3/0/ with 1 occurrences migrated to:
  https://contributor-covenant.org/version/1/3/0/ ([https](https://contributor-covenant.org/version/1/3/0/) result 301).
* http://inaka.github.com/apns4erl with 1 occurrences migrated to:
  https://inaka.github.com/apns4erl ([https](https://inaka.github.com/apns4erl) result 301).
* http://inaka.github.com/edis/ with 1 occurrences migrated to:
  https://inaka.github.com/edis/ ([https](https://inaka.github.com/edis/) result 301).
* http://lasp-lang.org/ with 1 occurrences migrated to:
  https://lasp-lang.org/ ([https](https://lasp-lang.org/) result 301).
* http://rabbitmq.com/documentation.html with 1 occurrences migrated to:
  https://rabbitmq.com/documentation.html ([https](https://rabbitmq.com/documentation.html) result 301).
* http://saleyn.github.com/erlexec with 1 occurrences migrated to:
  https://saleyn.github.com/erlexec ([https](https://saleyn.github.com/erlexec) result 301).
* http://www.mozilla.org/MPL/ with 290 occurrences migrated to:
  https://www.mozilla.org/MPL/ ([https](https://www.mozilla.org/MPL/) result 301).
* http://zhongwencool.github.io/observer_cli with 1 occurrences migrated to:
  https://zhongwencool.github.io/observer_cli ([https](https://zhongwencool.github.io/observer_cli) result 301).
2019-03-20 03:13:07 -05:00
Michael Klishin ddf09a9cd8 Normalize formatter name
So that json, JSON, Json all work the same way.
This is because we will use "JSON" in command docs
so eventually a user will try that value verbatim.
2019-03-18 07:47:45 +03:00
Daniil Fedotov 8bae6cd929 Add behaviour helpers.
Instead of calling function_exported? every time to access behaviour
functions, call CommandBehaviour.function.

Isolate all function defaults in the CommandBehaviour module.

Add a macro to define constant command functions.
2019-02-11 14:03:19 -05:00
Michael Klishin db72acf1a3 Squash a couple of warnings 2019-02-03 06:20:04 +03:00
Jean-Sébastien Pédron e22936b38c New `pretty_table` formatter
Use it by specifying the following flag on the command line:
  --formatter pretty_table

Tables are printed using ANSI line drawing (or ASCII characters) and
colors.

Example:

    Listing queues for vhost / ...
    ┌──────┬──────────┬──────────────────┐
    │ name │ messages │ pid              │
    ├──────┼──────────┼──────────────────┤
    │ b    │ 0        │ #PID<9901.899.0> │
    ├──────┼──────────┼──────────────────┤
    │ c    │ 0        │ #PID<9901.914.0> │
    ├──────┼──────────┼──────────────────┤
    │ a    │ 0        │ #PID<9901.887.0> │
    └──────┴──────────┴──────────────────┘

Internally, it uses the `rabbit_pretty_stdout` module from
rabbitmq-common.
2019-02-01 17:51:24 +01:00
Daniil Fedotov 91bb84bc82 Move table_headers parameter definition to formatter.
Since #301 formatters support their own parameters
2019-01-30 16:02:11 -05:00
Michael Klishin 94b55d71fa Format with `gmake format` 2019-01-30 22:20:29 +03:00
Michael Klishin 7c44eeb0d9 Move get_formatter/2, get_printer/2 and friends to RabbitMQ.CLI.Core.Config
To avoid RabbitMQCtl being used as a library module and because
they both are effectively generic configurable settings.
2019-01-24 11:11:04 +03:00
Daniil Fedotov e6530d6799 Make it possible for formatters to define arguments.
Add new callbacks to formatter_behavior: switches/0 and aliases/0
Merge them with command switches and aliases on parsing.

There is an example switch in the table formatter, enabling header padding.
2019-01-23 18:04:12 -05:00
Michael Klishin 1722a085d9 JSON formatter: flatten the stream before formatting
Otherwise JSON array items are enclosed in an array, which unlikely
was the intent.

(cherry picked from commit b66751490798d1b374a0ffde73307b84f510f420)
2019-01-22 11:49:27 +03:00
Michael Klishin 84c1d51c92 Introducee rabbitmq-plugins is_enabled [plugin 1] [plugin 2] [...]
Part of #292.
2019-01-21 11:02:10 +03:00
Michael Klishin b6f4d75afc Update (c) year 2019-01-20 06:10:59 +03:00
Michael Klishin 9479a466f5 Revert "Pad info items in the table formatter to be at least as wide as header."
This reverts commit fc4264224a.

This is a breaking change for tools that parse list_* command tables
and after revisiting our own test suites I'm not sure it's worth the burden.
2018-12-29 01:44:16 +03:00
Daniil Fedotov fc4264224a Pad info items in the table formatter to be at least as wide as header. 2018-12-28 17:42:21 +04:00
Michael Klishin d0ea645ea3 New command: rabbitmq-diagnostics tls_versions
Like cipher_suites but for supported (available in the runtime)
TLS versions.

[#162832991]
2018-12-24 15:25:35 +03:00
Michael Klishin e0e33f4b73 New diagnostics command: runtime_thread_stats
Uses Erlang's microstate accounting data to produce
high level thread state/activity breakdown.

Per discussion with @gerhard.
2018-12-07 18:43:48 +03:00
Luke Bakken 8ab22299a8 Document --no-table-headers
Fixes #274

Switch no_table_headers to table_headers

update tests

Integrate --silent
2018-11-19 15:25:36 -08:00
Daniil Fedotov 915004de25 Make CSV formatter return a string from format_output
By default CSV.encode returns a stream. Plain-value output does not
support streams.
2018-11-01 10:22:56 +00:00
Michael Klishin 5e54354fdf Make it possible to suppress table headers for list_* commands
Using --no-table-headers, per discussion with @dumbbell.
2018-10-24 16:43:58 +03:00
Daniil Fedotov 222e486ca7 Add headers to the table formatter.
There were headers in 3.6 CLI which were not implemented when moving
to the new one.

Fixes #264
[#161326468]
2018-10-22 10:55:16 +01:00
Ayanda Dube c88cfd940d Reduce code footprint on aliases 2018-07-23 06:06:18 +01:00
Luke Bakken 08c3100897 Add function clause for set: case
Fixes #241
2018-02-13 09:08:59 -08:00
Daniil Fedotov 81c1f9461f Add an output formatter for report command
Report command executes other commands, so it's formatter
cannot be changed using command line argument.
Report formatter will format each command output with this command
default formatter.
2017-06-15 16:32:39 +01:00
kjnilsson 93b42d5e31 Log enabled and disabled plugins in offline mode.
This ensures that the enabled/disabled plugins are logged
in offline mode.

[#146384227]
2017-06-13 10:01:32 +01:00
Daniil Fedotov 14cb785966 Unused clause 2017-06-02 10:17:28 +01:00
Daniil Fedotov 769fe8e712 Better error management with stream outputs from list_ commands.
Fixed incorrect tuple matching.
Added support for error codes and messages for timeout with value.
2017-05-24 13:28:51 +01:00
Daniil Fedotov 60deb8514d Improve error reporting.
badrpc errors are handled in Rabbitmqctl module.
Report errors from node discovery
Add helpers to skip errors in formatters.
2017-05-24 12:08:03 +01:00
Daniil Fedotov 719b75269c Fixing erlang and string formatters.
Erlang formatter had issues when formatting erlang strings, because
they were interpreted as streams. Now all streams are being converted
to lists and printed as is.
String formatter does not try to format with io_lib, instead it tries
to format using Elixir to_string.
2017-05-22 17:14:26 +01:00
Daniil Fedotov 8ef4c404ab Do not import modules. Import only protocols and records.
Aliases is a convinient enough to reference elixir modules.
Imported functions can be confusing, especially mixed with aliases.
2017-04-05 11:59:54 +01:00
Daniil Fedotov 819d512038 Implement shutdown command 2017-04-04 19:23:50 +01:00
Daniil Fedotov 0e13568ec3 Move plugin validation from `validate` to `run` 2017-01-27 14:55:09 +00:00
Jean-Sébastien Pédron 5905f1c40a Update copyright line to year 2017 2017-01-10 15:42:40 +01:00
Michael Klishin ad094d74a9 Correct delegation here 2016-12-12 16:27:34 +03:00
Michael Klishin 1f7404ce4c Don't include double quotes in cookie hash output
It is easier to parse, in particular when -q is passed.
2016-12-12 15:51:29 +03:00
Daniil Fedotov f7a741ece8 Merge branch 'master' into rabbitmq-cli-134 2016-12-07 14:05:59 +00:00
Michael Klishin 216810d205 Drive by change: simplify 2016-12-07 15:47:28 +03:00