Document arguments/options and relevant guides for more commands

This commit is contained in:
Michael Klishin 2019-03-30 09:30:26 +03:00
parent 6cf71362d1
commit 171376f9c9
24 changed files with 242 additions and 27 deletions

View File

@ -158,7 +158,7 @@ Then the alias can be called like this:
```
rabbitmqctl delete_vhost_queues -p vhost1
# or
rabbitmqctl delete_vhost_queues ---vhost vhost1
rabbitmqctl delete_vhost_queues ---vhost <vhost>1
```
Keep in mind that `eval` command can accept only [global arguments](#global-arguments) as named,

View File

@ -41,11 +41,15 @@ defmodule RabbitMQ.CLI.Core.DocGuide do
# API
#
Macros.defguide("access_control")
Macros.defguide("alternate_exchange", path_segment: "ae")
Macros.defguide("cli")
Macros.defguide("clustering")
Macros.defguide("cluster_formation")
Macros.defguide("connections")
Macros.defguide("configuration", path_segment: "configure")
Macros.defguide("consumers")
Macros.defguide("mirroring", path_segment: "ha")
Macros.defguide("logging")
Macros.defguide("management")
Macros.defguide("monitoring")
@ -53,4 +57,6 @@ defmodule RabbitMQ.CLI.Core.DocGuide do
Macros.defguide("plugins")
Macros.defguide("queues")
Macros.defguide("quorum_queues", domain: "next.rabbitmq.com")
Macros.defguide("troubleshooting")
Macros.defguide("virtual_hosts", path_segments: "vhosts")
end

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.AddUserCommand do
alias RabbitMQ.CLI.Core.{ExitCodes, Helpers}
alias RabbitMQ.CLI.Core.{DocGuide, ExitCodes, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
@ -54,6 +54,12 @@ defmodule RabbitMQ.CLI.Ctl.Commands.AddUserCommand do
]
end
def usage_doc_guides() do
[
DocGuide.access_control()
]
end
def help_section(), do: :user_management
def description(), do: "Creates a new user in the internal database"

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.AddVhostCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
@ -30,6 +30,18 @@ defmodule RabbitMQ.CLI.Ctl.Commands.AddVhostCommand do
def usage, do: "add_vhost <vhost>"
def usage_additional() do
[
["<vhost>", "Virtual host name"]
]
end
def usage_doc_guides() do
[
DocGuide.virtual_hosts()
]
end
def help_section(), do: :virtual_hosts
def description(), do: "Creates a virtual host"

View File

@ -14,6 +14,8 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.AuthenticateUserCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
def merge_defaults(args, opts), do: {args, opts}
@ -42,6 +44,11 @@ defmodule RabbitMQ.CLI.Ctl.Commands.AuthenticateUserCommand do
]
end
def usage_doc_guides() do
[
DocGuide.access_control()
]
end
def help_section(), do: :user_management

View File

@ -14,6 +14,8 @@
## Copyright (c) 2016-2017 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.CancelSyncQueueCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.DefaultOutput
@ -35,7 +37,19 @@ defmodule RabbitMQ.CLI.Ctl.Commands.CancelSyncQueueCommand do
)
end
def usage, do: "cancel_sync_queue [--vhost <vhost>] queue"
def usage, do: "cancel_sync_queue [--vhost <vhost>] <queue>"
def usage_additional() do
[
["<queue>", "Queue name"]
]
end
def usage_doc_guides() do
[
DocGuide.mirroring()
]
end
def help_section(), do: :replication

View File

@ -14,6 +14,8 @@
## Copyright (c) 2016-2017 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.ChangeClusterNodeTypeCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
def merge_defaults(args, opts) do
@ -50,7 +52,19 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ChangeClusterNodeTypeCommand do
end
def usage() do
"change_cluster_node_type <disc|ram>"
"change_cluster_node_type <disc | ram>"
end
def usage_additional() do
[
["<disc | ram>", "New node type"]
]
end
def usage_doc_guides() do
[
DocGuide.clustering()
]
end
def help_section(), do: :cluster_management

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.ChangePasswordCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.DefaultOutput
@ -37,6 +37,19 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ChangePasswordCommand do
def usage, do: "change_password <username> <password>"
def usage_additional() do
[
["<username>", "Name of the user whose password should be changed"],
["<password>", "New password to set"]
]
end
def usage_doc_guides() do
[
DocGuide.access_control()
]
end
def help_section(), do: :user_management
def description(), do: "Changes the user password"

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.ClearPasswordCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
@ -34,9 +34,22 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClearPasswordCommand do
use RabbitMQ.CLI.DefaultOutput
def usage, do: "clear_password <username>"
def usage_additional() do
[
["<username>", "Name of the user whose password should be cleared"]
]
end
def usage_doc_guides() do
[
DocGuide.access_control()
]
end
def help_section(), do: :user_management
def description(), do: "Removes the user password"
def description(), do: "Clears (resets) password and disables password login for a user"
def banner([user], _), do: "Clearing password for user \"#{user}\" ..."
end

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.ClearPermissionsCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
@ -35,7 +35,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClearPermissionsCommand do
use RabbitMQ.CLI.DefaultOutput
def usage, do: "clear_permissions [-p vhost] <username>"
def usage, do: "clear_permissions [--vhost <vhost>] <username>"
def usage_additional() do
[
@ -43,6 +43,11 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClearPermissionsCommand do
]
end
def usage_doc_guides() do
[
DocGuide.access_control()
]
end
def help_section(), do: :access_control
def description(), do: "Revokes user permissions for a vhost"

View File

@ -38,7 +38,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClearPolicyCommand do
def usage_additional() do
[
["<name>", "name of policy to clear (remove)"]
["<name>", "Name of policy to clear (remove)"]
]
end

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.ClearTopicPermissionsCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.DefaultOutput
@ -53,7 +53,21 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClearTopicPermissionsCommand do
])
end
def usage, do: "clear_topic_permissions [-p vhost] <username> [<exchange>]"
def usage, do: "clear_topic_permissions [--vhost <vhost>] <username> [<exchange>]"
def usage_additional() do
[
["<username>", "Name of the user whose topic permissions should be revoked"],
["<exchange>", "Exchange the permissions are for"]
]
end
def usage_doc_guides() do
[
DocGuide.access_control()
]
end
def help_section(), do: :access_control
def description(), do: "Clears user topic permissions for a vhost or exchange"

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.ClearVhostLimitsCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.DefaultOutput
@ -36,6 +36,12 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClearVhostLimitsCommand do
def usage, do: "clear_vhost_limits [--vhost <vhost>]"
def usage_doc_guides() do
[
DocGuide.virtual_hosts()
]
end
def help_section(), do: :virtual_hosts
def description(), do: "Clears virtual host limits"

View File

@ -14,6 +14,8 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.CloseAllConnectionsCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
def switches(), do: [global: :boolean, per_connection_delay: :integer, limit: :integer]
@ -78,7 +80,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.CloseAllConnectionsCommand do
end
def usage do
"close_all_connections [-p <vhost> --limit <limit>] [-n <node> --global] [--per-connection-delay <delay>] <explanation>"
"close_all_connections [--vhost <vhost> --limit <limit>] [-n <node> --global] [--per-connection-delay <delay>] <explanation>"
end
def usage_additional do
@ -89,6 +91,12 @@ defmodule RabbitMQ.CLI.Ctl.Commands.CloseAllConnectionsCommand do
]
end
def usage_doc_guides() do
[
DocGuide.connections()
]
end
def help_section(), do: :operations
def description(), do: "Instructs the broker to close all connections for the specified vhost or entire RabbitMQ node"

View File

@ -14,6 +14,8 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.CloseConnectionCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.Core.MergesNoDefaults
@ -32,6 +34,19 @@ defmodule RabbitMQ.CLI.Ctl.Commands.CloseConnectionCommand do
def usage, do: "close_connection <connection pid> <explanation>"
def usage_additional do
[
["<connection pid>", "connection identifier (Erlang PID), see list_connections"],
["<explanation>", "reason for connection closure"]
]
end
def usage_doc_guides() do
[
DocGuide.connections()
]
end
def help_section(), do: :operations
def description(), do: "Instructs the broker to close the connection associated with the Erlang process id"

View File

@ -14,6 +14,8 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.ClusterStatusCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
def scopes(), do: [:ctl, :diagnostics]
@ -48,6 +50,14 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClusterStatusCommand do
def usage, do: "cluster_status"
def usage_doc_guides() do
[
DocGuide.clustering(),
DocGuide.cluster_formation(),
DocGuide.monitoring()
]
end
def help_section(), do: :cluster_management
def description(), do: "Displays all the nodes in the cluster grouped by node type, together with the currently running nodes"

View File

@ -16,6 +16,8 @@
alias RabbitMQ.CLI.Core.Helpers
defmodule RabbitMQ.CLI.Ctl.Commands.DecodeCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.DefaultOutput
@ -42,7 +44,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecodeCommand do
end
def validate(args, _) when length(args) < 2 do
{:validation_failure, {:bad_argument, "Please provide a value to decode and a passphrase."}}
{:validation_failure, {:bad_argument, "Please provide a value to decode and a passphrase"}}
end
def validate(args, _) when length(args) > 2 do
@ -52,7 +54,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecodeCommand do
def validate(args, opts) when length(args) === 2 do
case {supports_cipher(opts.cipher), supports_hash(opts.hash), opts.iterations > 0} do
{false, _, _} ->
{:validation_failure, {:bad_argument, "The requested cipher is not supported."}}
{:validation_failure, {:bad_argument, "The requested cipher is not supported"}}
{_, false, _} ->
{:validation_failure, {:bad_argument, "The requested hash is not supported"}}
@ -104,6 +106,12 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DecodeCommand do
]
end
def usage_doc_guides() do
[
DocGuide.configuration()
]
end
def help_section(), do: :configuration
def description(), do: "Decrypts an encrypted configuration value"

View File

@ -14,6 +14,8 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.DeleteQueueCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
def switches(), do: [if_empty: :boolean, if_unused: :boolean, timeout: :integer]
@ -119,6 +121,11 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DeleteQueueCommand do
]
end
def usage_doc_guides() do
[
DocGuide.queues()
]
end
def help_section(), do: :queues

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.DeleteUserCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
@ -34,9 +34,22 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DeleteUserCommand do
use RabbitMQ.CLI.DefaultOutput
def usage, do: "delete_user <username>"
def usage_additional() do
[
["<username>", "Name of the user to delete."]
]
end
def usage_doc_guides() do
[
DocGuide.queues()
]
end
def help_section(), do: :user_management
def description(), do: "Removes the specified user"
def description(), do: "Removes a user from the internal database. Has no effect on users provided by external backends such as LDAP"
def banner([arg], _), do: "Deleting user \"#{arg}\" ..."
end

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.DeleteVhostCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
@ -30,6 +30,18 @@ defmodule RabbitMQ.CLI.Ctl.Commands.DeleteVhostCommand do
def usage, do: "delete_vhost <vhost>"
def usage_additional() do
[
["<vhost>", "Name of the virtual host to delete."]
]
end
def usage_doc_guides() do
[
DocGuide.virtual_hosts()
]
end
def help_section(), do: :virtual_hosts
def description(), do: "Deletes a virtual host"

View File

@ -14,7 +14,7 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.EncodeCommand do
alias RabbitMQ.CLI.Core.Helpers
alias RabbitMQ.CLI.Core.{DocGuide, Helpers}
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.DefaultOutput
@ -94,6 +94,12 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EncodeCommand do
]
end
def usage_doc_guides() do
[
DocGuide.configuration()
]
end
def help_section(), do: :configuration
def description(), do: "Encrypts a sensitive configuration value"

View File

@ -14,6 +14,8 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.EvalCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.Core.MergesNoDefaults
@ -47,11 +49,25 @@ defmodule RabbitMQ.CLI.Ctl.Commands.EvalCommand do
def formatter(), do: RabbitMQ.CLI.Formatters.Erlang
def usage, do: "eval <expr>"
def usage, do: "eval <expression>"
def usage_additional() do
[
["<expression>", "Expression to evaluate"]
]
end
def usage_doc_guides() do
[
DocGuide.cli(),
DocGuide.monitoring(),
DocGuide.troubleshooting()
]
end
def help_section(), do: :operations
def description(), do: "Executes Erlang code on the RabbitMQ node"
def description(), do: "Evaluates a snippet of Erlang code on the target node"
def banner(_, _), do: nil

View File

@ -14,6 +14,8 @@
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
defmodule RabbitMQ.CLI.Ctl.Commands.ExecCommand do
alias RabbitMQ.CLI.Core.DocGuide
@behaviour RabbitMQ.CLI.CommandBehaviour
use RabbitMQ.CLI.Core.MergesNoDefaults
@ -64,16 +66,24 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ExecCommand do
def banner(_, _), do: nil
def usage, do: "exec <expr> [--offline]"
def usage, do: "exec <expression> [--offline]"
def usage_additional() do
[
["--offline", "do not initialize Erlang distribution"]
["<expression>", "Expression to evaluate"],
["--offline", "disable inter-node communication"]
]
end
def usage_doc_guides() do
[
DocGuide.cli(),
DocGuide.monitoring(),
DocGuide.troubleshooting()
]
end
def help_section(), do: :operations
def description(), do: "Executes Elixir code on the CLI node"
def description(), do: "Evaluates a snippet of Elixir code on the CLI node"
end

View File

@ -68,7 +68,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ListConsumersCommand do
def formatter(), do: RabbitMQ.CLI.Formatters.Table
def usage() do
"list_consumers [-p vhost] [--no-table-headers] [<column> ...]"
"list_consumers [--vhost <vhost>] [--no-table-headers] [<column> ...]"
end
def help_section(), do: :observability_and_health_checks