Seely.Main (Seely v0.1.0) View Source
The main process (GenServer) for the CLI global handling.
It is usually started from your Application's supervision tree as a child
def start(_type, _args) do
children = [
#...,
{Seely.Main, [YourRouter]}
]
opts = [strategy: :one_for_one, name: YourApp.Supervisor]
Supervisor.start_link(children, opts)
end
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Start the CLI loop
Get the router of the main process
Get the pid of the Main process or nil
Find a session by pid or name. Returns the pid when registered or nil.
Get the name of session by pid
Get a list of all registered sessions as
Start the Main GenServer with the given router_module
(YourRouter
)
Start a new session. Returns {:ok, pid}
or {:error, ...}
Stop all sessions
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Start the CLI loop
The user will see a prompt "CLI (count)>" where count
is just a continues
counter for the command in this session, starting at 1.
When a route for the entered command can be find, it will be executed and the result will be printed to stdio.
Unless the entered command is exit
, the loop will repeat with the next prompt.
Example
iex> cli
CLI(1) echo Hello, world!
{:ok, "Hello, world!"}
CLI(2) exit
iex>
Get the router of the main process
Get the pid of the Main process or nil
Find a session by pid or name. Returns the pid when registered or nil.
Get the name of session by pid
Get a list of all registered sessions as
[{"Session 1", pid1}, {"Session 2", pid2}, ...]
Start the Main GenServer with the given router_module
(YourRouter
)
Start a new session. Returns {:ok, pid}
or {:error, ...}
Stop all sessions