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.
|
2017-01-10 22:42:40 +08:00
|
|
|
## Copyright (c) 2007-2017 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]
|
2016-11-04 19:29:14 +08:00
|
|
|
@callback validate(List.t, Map.t) :: :ok | {:validation_failure, Atom.t | {Atom.t, String.t}}
|
2016-05-24 19:33:11 +08:00
|
|
|
@callback merge_defaults(List.t, Map.t) :: {List.t, Map.t}
|
2017-06-07 21:22:59 +08:00
|
|
|
@callback banner(List.t, Map.t) :: String.t | nil
|
2016-11-04 19:11:03 +08:00
|
|
|
@callback run(List.t, Map.t) :: 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
|
|
|
|
@callback output(any, Map.t) :: :ok | {:ok, any} | {:stream, Enum.t} |
|
|
|
|
{:error, ExitCodes.exit_code, [String.t]}
|
|
|
|
@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 20:08:37 +08:00
|
|
|
required_rabbit_app_state: 2,
|
|
|
|
validate_execution_environment: 2
|
2016-11-22 21:11:25 +08:00
|
|
|
|
|
|
|
@callback switches() :: Keyword.t
|
|
|
|
@callback aliases() :: Keyword.t
|
|
|
|
|
2016-11-04 19:29:14 +08:00
|
|
|
@callback formatter() :: Atom.t
|
|
|
|
@callback scopes() :: [Atom.t]
|
|
|
|
@callback usage_additional() :: String.t | [String.t]
|
2016-05-05 05:03:09 +08:00
|
|
|
end
|