2016-05-05 05:03:09 +08:00
|
|
|
## The contents of this file are subject to the Mozilla Public License
|
|
|
|
## Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
## compliance with the License. You may obtain a copy of the License
|
|
|
|
## at http://www.mozilla.org/MPL/
|
|
|
|
##
|
|
|
|
## Software distributed under the License is distributed on an "AS IS"
|
|
|
|
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
|
## the License for the specific language governing rights and
|
|
|
|
## limitations under the License.
|
|
|
|
##
|
|
|
|
## The Original Code is RabbitMQ.
|
|
|
|
##
|
|
|
|
## The Initial Developer of the Original Code is GoPivotal, Inc.
|
2019-01-20 11:10:59 +08:00
|
|
|
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
|
2016-05-05 05:03:09 +08:00
|
|
|
|
|
|
|
|
2016-06-10 07:54:22 +08:00
|
|
|
defmodule RabbitMQ.CLI.CommandBehaviour do
|
2016-05-05 07:00:12 +08:00
|
|
|
@callback usage() :: String.t | [String.t]
|
2017-08-04 23:40:17 +08:00
|
|
|
# validates CLI arguments
|
2017-08-14 21:36:38 +08:00
|
|
|
@callback validate(list(), map()) :: :ok | {:validation_failure, atom() | {atom(), String.t}}
|
|
|
|
@callback merge_defaults(list(), map()) :: {list(), map()}
|
2017-08-14 21:40:35 +08:00
|
|
|
@callback banner(list(), map()) :: [String.t] | String.t | nil
|
2017-08-14 21:36:38 +08:00
|
|
|
@callback run(list(), map()) :: any
|
2016-09-05 18:29:11 +08:00
|
|
|
# Coerces run/2 return value into the standard command output form
|
|
|
|
# that is then formatted, printed and returned as an exit code.
|
2016-11-04 19:29:14 +08:00
|
|
|
# There is a default implementation for this callback in DefaultOutput module
|
2017-08-14 21:36:38 +08:00
|
|
|
@callback output(any, map()) :: :ok | {:ok, any} | {:stream, Enum.t} |
|
|
|
|
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_code, [String.t]}
|
2016-11-04 19:29:14 +08:00
|
|
|
@optional_callbacks formatter: 0,
|
|
|
|
scopes: 0,
|
2016-11-22 21:11:25 +08:00
|
|
|
usage_additional: 0,
|
|
|
|
switches: 0,
|
2017-08-04 19:09:37 +08:00
|
|
|
aliases: 0,
|
2017-08-04 23:40:17 +08:00
|
|
|
# validates execution environment, e.g. file presence,
|
|
|
|
# whether RabbitMQ is in an expected state on a node, etc
|
2017-12-07 02:10:11 +08:00
|
|
|
validate_execution_environment: 2,
|
|
|
|
distribution: 1
|
2016-11-22 21:11:25 +08:00
|
|
|
|
2017-08-14 21:40:35 +08:00
|
|
|
@callback validate_execution_environment(list(), map()) :: :ok | {:validation_failure, atom() | {atom(), any}}
|
2016-11-22 21:11:25 +08:00
|
|
|
@callback switches() :: Keyword.t
|
|
|
|
@callback aliases() :: Keyword.t
|
|
|
|
|
2017-08-14 21:36:38 +08:00
|
|
|
@callback formatter() :: atom()
|
|
|
|
@callback scopes() :: [atom()]
|
2016-11-04 19:29:14 +08:00
|
|
|
@callback usage_additional() :: String.t | [String.t]
|
2017-12-07 02:10:11 +08:00
|
|
|
## Erlang distribution control
|
|
|
|
## :cli - default rabbitmqctl generated node name
|
|
|
|
## :none - disable erlang distribution
|
|
|
|
## {:fun, fun} - use a custom function to start distribution
|
|
|
|
@callback distribution(map()) :: :cli | :none | {:fun, ((map()) -> :ok | {:error, any()})}
|
2016-05-05 05:03:09 +08:00
|
|
|
end
|