1 |
|
%% @doc Short functions useful for config file manipulations. |
2 |
|
%% This stuff can be pure, but most likely not. |
3 |
|
%% It's for generic functions. |
4 |
|
-module(mongoose_config_utils). |
5 |
|
-export([exit_or_halt/1]). |
6 |
|
-export([section_to_defaults/1]). |
7 |
|
-ignore_xref([section_to_defaults/1]). |
8 |
|
|
9 |
|
-include("mongoose_config_spec.hrl"). |
10 |
|
|
11 |
|
%% @doc If MongooseIM isn't yet running in this node, then halt the node |
12 |
|
-spec exit_or_halt(ExitText :: string()) -> none(). |
13 |
|
exit_or_halt(ExitText) -> |
14 |
:-( |
case [Vsn || {mongooseim, _Desc, Vsn} <- application:which_applications()] of |
15 |
|
[] -> |
16 |
:-( |
timer:sleep(1000), |
17 |
:-( |
halt(string:substr(ExitText, 1, 199)); |
18 |
|
[_] -> |
19 |
:-( |
exit(ExitText) |
20 |
|
end. |
21 |
|
|
22 |
|
section_to_defaults(#section{defaults = Defaults}) -> |
23 |
:-( |
Defaults. |