Packages
nerves_runtime
0.3.0
0.13.13
0.13.12
0.13.11
retired
0.13.10
0.13.9
0.13.8
0.13.7
0.13.6
0.13.5
0.13.4
0.13.3
0.13.2
0.13.1
0.13.0
0.12.0
0.11.10
0.11.9
0.11.8
0.11.7
0.11.6
0.11.5
0.11.4
0.11.3
0.11.2
0.11.1
0.11.0
0.10.3
0.10.2
0.10.1
0.10.0
retired
0.9.5
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.0
0.7.0
0.6.5
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.3
0.5.2
0.5.1
0.5.0
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.1
0.3.0
0.2.0
0.1.2
0.1.1
0.1.0
Small, general runtime utilities for Nerves devices
Current section
Files
Jump to
Current section
Files
lib/nerves_runtime/shell.ex
defmodule Nerves.Runtime.Shell do
@moduledoc """
Entry point for a primitive command shell available through Erlang's job
control mode. To use, type Ctrl+G at an iex prompt to enter job control mode.
At the prompt, type `s sh` and then `c` to connect to it. To return to the
iex prompt, type Ctrl+G again and `c 1`.
Here's an example session:
```
iex> [Ctrl+G]
User switch command
--> s sh
--> j
1 {erlang,apply,[#Fun<Elixir.IEx.CLI.1.112225073>,[]]}
2* {'Elixir.Nerves.Runtime.Shell',start,[]}
--> c
Nerves Interactive Host Shell
sh[1]> find . -name "shell.ex"
./lib/nerves_runtime/shell.ex
sh[2]> [Ctrl+G]
User switch command
--> c 1
nil
iex>
```
"""
alias Nerves.Runtime.Shell.Server
@doc """
This is the callback invoked by Erlang's shell when someone presses Ctrl+G
and types `s Elixir.Nerves.Runtime.Shell` or `s sh`.
"""
def start(opts \\ [], mfa \\ {Nerves.Runtime.Shell, :dont_display_result, []}) do
spawn(fn ->
# The shell should not start until the system is up and running.
case :init.notify_when_started(self()) do
:started -> :ok
_ -> :init.wait_until_started()
end
# Make sure the OTP app fires up since we came in through the shell's
# job control mode.
{:ok, _} = Application.ensure_all_started(:nerves_runtime)
:io.setopts(Process.group_leader, binary: true, encoding: :unicode)
Server.start(opts, mfa)
end)
end
def dont_display_result, do: "don't display result"
end
defmodule :sh do
@moduledoc """
This is a shortcut for invoking `Nerves.Runtime.Shell` in the Erlang job
control menu. The alternative is to type `:Elixir.Nerves.Runtime.Shell` at
the `s [shell]` prompt.
"""
defdelegate start, to: Nerves.Runtime.Shell
end