Adify v0.1.0 Adify.SystemInfo

This module is used to get system's information. Information like OS type, Distribution, Kernel, Package Managers etc

Link to this section Summary

Functions

Wrapper around Elixir's System command. Runs a command on the CLI

Returns the current os

Returns whether an OS is valid for adifying

Link to this section Functions

Link to this function

cmd(cmd, env \\ [], cd \\ ".")
cmd(String.t(), [{String.t(), String.t()}], Path.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Wrapper around Elixir's System command. Runs a command on the CLI.

Examples:

# When the command is valid
iex> cmd = "echo hi"
iex> {:ok, output} = Adify.SystemInfo.cmd(cmd)
iex> output =~ "hi"
true

# When the command is invalid
iex> cmd = "bad_command"
iex> {:error, output}  = Adify.SystemInfo.cmd(cmd, [], ".")
iex> output =~ "bad_command"
true
Link to this function

current_os()
current_os() :: {:ok, String.t()} | {:error, term()}

Returns the current os

Examples

# If uname returns Darwin, it's osx
iex> {:ok, output} = Adify.SystemInfo.cmd("uname", [], ".")
iex> (output =~ "Darwin") ==
...>   (Adify.SystemInfo.current_os == {:ok, "osx"})
true

# If uname returns Linux, it's not osx
iex> {:ok, output} = Adify.SystemInfo.cmd("uname", [], ".")
iex> (output =~ "Linux") ==
...>   (Adify.SystemInfo.current_os != {:ok, "osx"})
true
Link to this function

valid_os?(os)
valid_os?(String.t()) :: boolean()

Returns whether an OS is valid for adifying

Examples

# When os is osx
iex> Adify.SystemInfo.valid_os?("osx")
true

# When os is arch_linux
iex> Adify.SystemInfo.valid_os?("arch_linux")
true

# When os is ubuntu
iex> Adify.SystemInfo.valid_os?("ubuntu")
true

# When os is pop_os
iex> Adify.SystemInfo.valid_os?("ubuntu")
true

# When os is redox (not compatible with adify unfortunately)
iex> Adify.SystemInfo.valid_os?("redox")
false