From a2be29a556c4a6526718321cb1519a7ff7909f8c Mon Sep 17 00:00:00 2001 From: Brandon Shroyer Date: Tue, 2 Feb 2016 16:32:35 -0500 Subject: [PATCH] Add stub for usage message. --- deps/rabbitmq_cli/lib/cli.ex | 5 +++++ deps/rabbitmq_cli/test/cli_test.exs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/deps/rabbitmq_cli/lib/cli.ex b/deps/rabbitmq_cli/lib/cli.ex index 0036a69de5..4c442a5b4e 100644 --- a/deps/rabbitmq_cli/lib/cli.ex +++ b/deps/rabbitmq_cli/lib/cli.ex @@ -17,6 +17,10 @@ defmodule CLI do :net_kernel.stop() end + defp print_usage() do + IO.puts "Usage: TBD" + end + defp print_nodedown_error(options) do target_node = options[:node] || get_rabbit_hostname @@ -24,6 +28,7 @@ defmodule CLI do IO.puts "Error: unable to connect to node '#{target_node}': nodedown" end + defp run_command([], _), do: IO.puts print_usage defp run_command(["status"], options) do case result = status(options) do {:badrpc, :nodedown} -> print_nodedown_error(options) diff --git a/deps/rabbitmq_cli/test/cli_test.exs b/deps/rabbitmq_cli/test/cli_test.exs index d5f68d5d1f..7533a8b483 100644 --- a/deps/rabbitmq_cli/test/cli_test.exs +++ b/deps/rabbitmq_cli/test/cli_test.exs @@ -27,4 +27,12 @@ defmodule CLITest do command = ["status", "-n", "sandwich@pastrami"] assert capture_io(fn -> CLI.main(command) end) =~ ~r/unable to connect to node 'sandwich@pastrami'\: nodedown/ end + + test "Empty command shows usage message" do + assert capture_io(fn -> CLI.main([]) end) =~ ~r/Usage\:/ + end + + test "Empty command with options shows usage message" do + assert capture_io(fn -> CLI.main(["-n", "sandwich@pastrami"]) end) =~ ~r/Usage\:/ + end end