diff --git a/lib/nexus/cli.ex b/lib/nexus/cli.ex index 7266b79..6ac7d43 100644 --- a/lib/nexus/cli.ex +++ b/lib/nexus/cli.ex @@ -8,11 +8,13 @@ defmodule Nexus.CLI do @callback version :: String.t() @callback banner :: String.t() + @callback handle_input(cmd) :: :ok + when cmd: atom @callback handle_input(cmd, args) :: :ok when cmd: atom, - args: list + args: Nexus.Command.Input.t() - @optional_callbacks banner: 0, handle_input: 2 + @optional_callbacks banner: 0, handle_input: 2, handle_input: 1 @type t :: map diff --git a/lib/nexus/command_dispatcher.ex b/lib/nexus/command_dispatcher.ex index 461bcf1..be740d1 100644 --- a/lib/nexus/command_dispatcher.ex +++ b/lib/nexus/command_dispatcher.ex @@ -8,7 +8,14 @@ defmodule Nexus.CommandDispatcher do def dispatch!(%Command{} = spec, raw) do input = Parser.run!(raw, spec) - spec.module.handle_input(spec.name, input) + + case {spec.type, input.value} do + {:null, nil} -> + :ok = spec.module.handle_input(spec.name) + + _ -> + :ok = spec.module.handle_input(spec.name, input) + end end def dispatch!(module, raw) when is_binary(raw) do