Seely (Seely v0.1.0) View Source
Starting the main-process (a GenServer
) with a given router
Example
defmodule MyRouter do
def routes,
do: [
{"myfunc", MyController, :myfunc}
]
def parse_opts,
do: [
strict: [myoption: boolean]
]
end
defmodule MyController do
def myfunc(params \ [""], opts \ []) do
output =
if Keyword.get(opts, :myopt, false) do
... code with 'myopt' true ...
else
... code with 'myopt' false or not given
end
{:ok, output}
end
end
Seely.Main.start_link(MyRouter)
Seely.API.cli
CLI(1) myfunc --myopt
{:ok, "...code with 'myopt' on..."}
CLI(2) myfunc
{:ok, "...code with 'myopt' off..."}
CLI(3) exit
Link to this section Summary
Functions
Start the main process with the given router.
Link to this section Functions
Specs
Start the main process with the given router.
Returns {:ok, pid}
.
Usually this server pid won't be used because Main
is a named (singelton)
process. You can find the pid at any time with GenServer.whereis(Seely.Main)
.