Commit Graph

98 Commits

Author SHA1 Message Date
Luke Bakken 33cb21ee92
Follow up to #14132
#14132 introduced a small bug in the JSON output that was caught by CI.
2025-06-25 12:01:49 -07:00
Luke Bakken 00528cb1e8
Follow-up to 14101
Improvement in the code that @the-mikedavis noticed just before #14118 was merged.
2025-06-25 08:04:49 -07:00
Luke Bakken 75cd74a2f2
Fix JSON output for `rabbitmqctl environment`
Fixes #14101
2025-06-24 13:20:26 -07:00
Loïc Hoguin c5d150a7ef
Use Erlang.mk's native Elixir support for CLI
This avoids using Mix while compiling which simplifies
a number of things and let us do further build improvements
later on.

Elixir is only enabled from within rabbitmq_cli currently.

Eunit is disabled since there are only Elixir tests.

Dialyzer will force-enable Elixir in order to process
Elixir-compiled beam files.

This commit also includes a few changes that are
related:

 * The Erlang distribution will now be started for parallel-ct

 * Many unnecessary PROJECT_MOD lines have been removed

 * `eunit_formatters` has been removed, it provides little value

 * The new `maybe_flock` Erlang.mk function is used where possible

 * Build test deps when testing rabbitmq_cli (Mix won't do it anymore)

 * rabbitmq_ct_helpers now use the early plugins to have Dialyzer
   properly set up
2025-03-18 10:02:49 +01:00
Michael Klishin 968eefa1bb
Bump (c) line year
There are no functional changes to this massive diff.
2025-01-01 17:54:10 -05:00
Michael Klishin c2fdd73c4b Secret encoding: refine CLI tools
'ctl encode' is unfortunately name and targets
advanced.config commands.

This introduce a command that targets 'rabbitmq.conf'
values and has a more specific name.

Eventually 'ctl encode' will be aliased and deprecated,
although we still do not have an aliasing mechanism
and it won't be in scope for 4.0.
2024-08-13 12:29:28 -04:00
Michael Klishin a21a60958b CLI: placate Dialyzer 2024-05-08 23:33:36 -04:00
Michael Klishin 4a3806bd18 Makes PluginsFormatterTest pass 2024-05-08 20:03:29 -04:00
Péter Gömöri 69eb2b9c29 Don't show disabled plugins as pending upgrade
Since commit c0187ec15 the value of `running_version` is converted
to_string (`nil` would become the empty string). But the formatter
expected `running_version` to be `nil` if the plugin is not
running. This did not match and not running/not enabled plugins were
marked incorrectly as "pending upgrade to...".

For example:
```
$ rabbitmq-plugins list trust -q
[  ] rabbitmq_trust_store               (pending upgrade to 3.13.0+51.g9145b53)

$ rabbitmq-plugins list trust --formatter erlang -q
 #{status => running,format => normal,
  plugins =>
      [#{enabled => not_enabled,name => rabbitmq_trust_store,running => false,
         version => <<"3.13.0+51.g9145b53">>,running_version => <<>>}]}
```
2024-05-08 08:23:21 +02:00
Michael Klishin f414c2d512
More missed license header updates #9969 2024-02-05 11:53:50 -05:00
Michael Klishin 1b642353ca
Update (c) according to [1]
1. https://investors.broadcom.com/news-releases/news-release-details/broadcom-and-vmware-intend-close-transaction-november-22-2023
2023-11-21 23:18:22 -05:00
Michal Kuratczyk 5459975c5c
Revert "Use rabbit_json in the CLI"
This reverts commit 6c65715875.
2023-11-17 13:05:38 +01:00
Michal Kuratczyk 6c65715875
Use rabbit_json in the CLI
dep_json doesn't seem to be maintained
and it's unnecessary anyway, since we can
use rabbit_json, which uses thoas
2023-11-16 00:01:14 +01:00
Rin Kuryloski 59f5494df2 elixir syntax over erlang 2023-07-04 17:45:50 +02:00
Rin Kuryloski 42d29a5ca3 Run 'mix format' with elixir 1.15.2 2023-07-04 17:45:32 +02:00
Rin Kuryloski 8efc71eb9f Fix rabbitmqctl compilation under elixir 1.15.x 2023-07-04 17:45:04 +02:00
Michael Klishin ddf7926941 CLI: make input ordering preditable when formatting a table
if the input is given as a map.

References #7931, #7921
2023-04-24 14:50:31 +04:00
Rin Kuryloski bdb2046185
Add rabbitmq_cli dialyze to bazel (#7066)
* Add rabbitmq_cli dialyze to bazel

and fix a number of warnings

Because we stop mix from recompiling rabbit_common in bazel, many
unknown functions are reported, so this dialyzer analysis is somewhat
incomplete.

* Use erlang dialyzer for rabbitmq_cli rather than mix dialyzer

Since this resolves all of the rabbit functions, there are far fewer
unknown functions.

Requires yet to be released rules_erlang 3.9.2

* Temporarily use pre-release rules_erlang

So that checks can run on this PR without a release

* Fix additional dialyzer warnings in rabbitmq_cli

* rabbitmq_cli: mix format

* Additional fixes for ignored return values

* Revert "Temporarily use pre-release rules_erlang"

This reverts commit c16b5b6815.

* Use rules_erlang 3.9.2
2023-01-31 15:05:52 +01:00
Michael Klishin ec4f1dba7d
(c) year bump: 2022 => 2023 2023-01-01 23:17:36 -05:00
Michael Klishin 0cd8dff415
CLI: improve isolation of set_disk_free_limit tests 2022-11-01 16:39:35 +04:00
Ayanda Dube 4cbbaad2df mix format rabbitmq_cli 2022-10-02 18:54:11 +01:00
Michael Klishin c38a3d697d
Bump (c) year 2022-03-21 01:21:56 +04:00
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