Commit Graph

195 Commits

Author SHA1 Message Date
Michael Klishin 17526987c6
Bump (c) year 2021-02-14 00:54:01 +03:00
Michael Klishin 15ea3d3de0 Avoid double spacing between command lines
when no arguments are provided. This makes the output
consistent with that of `help' and `--help'.
2020-08-05 19:36:32 +03:00
dcorbacho 679ca254f3 Switch to Mozilla Public License 2.0 (MPL 2.0) 2020-07-11 19:23:07 +01:00
Michael Klishin 2101043257 Introduce a first class autocomplete command
Currently we have a --auto-complete magic argument which
does not show up in `help` and requires its argument to be
explcitly -- separated from the actual flag, which is
counter-intuitive.

This introduces a new autocomplete command which is delegated
to by --auto-complete, much like --help is simply a special
way of invoking the `help` command.

Closes #439
2020-07-02 07:29:40 +03:00
Michael Klishin 921d349e37 Make --help, help usage help messages consistent
* `help` printed an "Error:" at the top for no reason
 * `help [command]` with a non-existent command did not offer a suggestion
   like an attempt to invoke a non-existent command would
 * Exit codes were not consistent
 * `help --list-commands` had line break issues

With this change,

  * `help` is consistent with --help
  * `help [command]` is consistent with `[command] --help`
  * If a command is not found, either during the execution flow
    or `help [commnad]`, we consistently attempt a Jaro distance suggestion
  * Successful or effectively successful exits from the `help`
    command do not produce any error messages at the top
2020-06-29 03:57:52 +03:00
Michael Klishin d99cdd04f5 Introduce rabbitmq-upgrade await_online_quorum_plus_one
The readiness is similar to that of 'rabbitmq-diagnostics check_if_node_is_quorum_critical'
but this command awaits for it up to --timeout seconds.

While at it, refactor DefautOutput to detect and support JSON formatting
of most basic return values suc has :ok or {:error, map}.

Part of #408.
2020-04-22 01:25:55 +03: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
Michael Klishin 71212de9ee Introduce `rabbitmq-queues check_if_node_is_quorum_critical'
Mob: @kjnilsson and several other Pivots.

Part of #389.
2019-12-12 15:58:06 +03:00
Luke Bakken 1c3de98493 Ensure stack trace is always printed for certain errors
Errors like :badarg, :function_clause, etc indicate a serious error. It would be handy for users to immediately get the stack trace to tell us.
2019-11-18 17:39:29 -08:00
Luke Bakken 4fb9bab458 Handle case where import file does not exist or is zero-sized.
Fixup printing the real stacktrace when --print-stacktrace is used
2019-11-18 14:39:50 -08:00
Jean-Sébastien Pédron ed9de9d591 rabbitmqctl.ex: Don't call System.stacktrace()
... now we depend on Elixir 1.7+. We can use the new syntax or, in this
case, simply call `Exception.format_stacktrace()` without any argument:
it will take care of querying the stacktrace.

This fixes a warning reported by elixirc.
2019-09-03 15:19:56 +02:00
Michael Klishin 5589496678 Squash a few more compiler warnings 2019-07-08 15:55:37 +03:00
Daniil Fedotov 25b441ae53 Make it possible to specify a custom printer for commands. Add std_io_raw printer.
Log streaming should print data as received without adding new lines.
To do that std_io_printer just writes all output to the std_io.
2019-06-26 17:34:35 -04:00
Daniil Fedotov ff0372200a Command to print last N log messages from the default log. 2019-06-26 15:56:22 -04:00
Daniil Fedotov b42c7a62d5 Improve error stacktrace reporting. 2019-06-26 12:49:35 -04:00
Michael Klishin 37800cd83b Allow check_failed errors provide additional context
Primarily for for --formatter=json use cases.
2019-05-29 13:59:59 +01:00
Michael Klishin 8e7a02ff81 Naming 2019-04-25 20:13:39 +03:00
Michael Klishin 4cb2d05c9c Improve error reporting of invalid node names
While at it, format errors thrown in a few more risky
code paths.

Closes #345.
2019-04-25 17:15:25 +03:00
Michael Klishin a1de733dae list_feature_flags: handle missing rabbit_ff_extra modules on target node
Part of #343.

[#163980302]
2019-04-20 02:20:23 +03:00
Michael Klishin d54408b768 Restore Elixir 1.6.6 compatibility
That's the version used when producing Debian
packages. Why? Because bintrary.com/rabbitmq-erlang
only provides that version :/
2019-04-19 06:23:28 +03:00
Michael Klishin e87e83cc93 Don't print stack trace if no option is provided explicitly 2019-04-19 04:43:58 +03:00
Michael Klishin 361d0e05d9 Squash a warning 2019-04-19 02:26:03 +03:00
Michael Klishin 7615b2067c Print stack trace if command execution fails and --print-stacktrace was passed
Per discussion with @dumbbell.
2019-04-18 19:14:02 +04:00
Michael Klishin 11f0b45732 cluster_status: rework output format, support JSON formatter
[#165435068]
2019-04-18 04:00:05 +04:00
Michael Klishin 6219ba07b0 Remove a stray stack trace dump
Got accidentally committed in 8bae6cd929.
2019-03-21 19:06:26 +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
Michael Klishin bea9cf4486 Rework command-specific help
* Display command-specific options first instead of
  generic at the top
* Include one line command synopsis from --list-commands
  in the command-specific message
* List timeout in a separate section. It doesn't
  integrate very well with either command-specific
  or general section
* Format section headings as H2s in Markdown, this makes them stand out
* Assorted small formatting changes
* Update tests to be less fragile to copywriting changes
2019-03-17 13:54:18 +03:00
Michael Klishin ea6294be41 New command: `rabbitmqctl force_gc`
Developed as part of a live coding training session but can be
useful in practice, so let's keep it.

Per discussion with @hairyhum.
2019-02-21 19:11:30 +03:00
Michael Klishin 80993dc921 Merge branch 'master' into help-wip 2019-02-21 13:18:59 +03:00
Michael Klishin c7e8ab9b56 New command: version, closes #314 2019-02-14 15:10:22 +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
Daniil Fedotov d6789e60f2 A new way to display basic usage.
Do not show additional parameters info.
List commands as names and descriptions.
Group commands in sections.

New behaviour callbacks:
help_section/0 - atom name of a group to put command to. Default is :other
description/0 - single line description of the command. Printed in the commands list

Sections ans descriptions are WIP.
2019-02-08 15:33:17 -05:00
Michael Klishin b452733d73 Improve error message produced by `rabbitmqctl shutdown`
References #309.
2019-02-07 04:24:13 +03:00
Michael Klishin 41148d2f4d Mention --longnames in the generic diagnostics message
Note that more specific errors are coming from
rabbit_nodes_common.
2019-02-05 21:11:00 +03:00
Luke Bakken 95e5b78af6 Output a friendly error if a long node name is used but --longnames not specified 2019-02-05 08:56:04 -08:00
Michael Klishin a392d8e432 This clause is no longer necessary 2019-02-03 22:01:29 +03:00
Michael Klishin 56ac8d1cf7 shutdown: correctly wrap badrpc responses in validate/2 2019-02-03 22:00:11 +03:00
Michael Klishin 0053f67485 Support bare --help
Note that there's a different between the case with no arguments
(exits with EX_USAGE) and --help (exits successfully).

Per discussion with the team.

Closes #307.
2019-02-01 19:47:09 +03:00
Daniil Fedotov 5e5f4d461c Make it possible to get command help by typing 'rabbitmqctl mycommand --help'
Add a new default switch `help`
Add an alias `?`

Make rabbitmqctl display command help if this option is true for known commands.
2019-01-30 16:47:18 -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 5c4ed6b912 Format generic error triplets 2019-01-23 10:44:19 +03:00
Michael Klishin 4bc3e51461 Introduce rabbitmq-diagnostics check[_local]_alarms
References #292.
2019-01-22 13:28:42 +03:00
Michael Klishin b6f4d75afc Update (c) year 2019-01-20 06:10:59 +03:00
Michael Klishin ac653965f4 Improve error message formatting for rabbitmq-plugins commands
There are two main types of errors that I see in practice:

 * Insufficient enabled plugins file permission (or the file does not exist)
 * Enabled plugins file used by CLI tools does not match that of
   the target node

[#162757498]
2018-12-19 15:54:23 +03:00
Luke Bakken b523093c3e Port Erlang/OTP node name code to Elixir
Follow-up to #278

Add another test case, fix bugs

Add another test

Start converting to new code

Node name related code is in NodeName module

Distribution not needed for Helpers tests

Add test for rabbit@localhost when longnames in use

No need to guess on domain in this spot

Fix behavior on OS X
2018-12-05 11:23:17 -08:00