Skip to content

Commit c7d4499

Browse files
committed
Merge pull request atomvm#1630 from pguyot/w15/add-init-get_argument-1-notify_when_started-1
Add `init:get_argument/1`, `init:get_plain_arguments/0` and `init:notify_when_started/1` These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 670d89b + 141a272 commit c7d4499

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Added `io:fwrite/1,2,3` and `io:format/3` as well as few io functions required by remote shell
3333
- Added `code:is_loaded/1` and `code:which/1`
3434
- Added several `io_lib` functions including `io_lib:fwrite/2` and `io_lib:write_atom/1`
35+
- Added `init:get_argument/1`, `init:get_plain_arguments/0` and `init:notify_when_started/1`
3536

3637
### Fixed
3738
- ESP32: improved sntp sync speed from a cold boot.

libs/estdlib/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ set(ERLANG_MODULES
4141
gen_tcp_socket
4242
supervisor
4343
inet
44+
init
4445
io_lib
4546
io
4647
lists

libs/estdlib/src/init.erl

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
%
2+
% This file is part of AtomVM.
3+
%
4+
% Copyright 2025 Paul Guyot <pguyot@kallisys.net>
5+
%
6+
% Licensed under the Apache License, Version 2.0 (the "License");
7+
% you may not use this file except in compliance with the License.
8+
% You may obtain a copy of the License at
9+
%
10+
% http://www.apache.org/licenses/LICENSE-2.0
11+
%
12+
% Unless required by applicable law or agreed to in writing, software
13+
% distributed under the License is distributed on an "AS IS" BASIS,
14+
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
% See the License for the specific language governing permissions and
16+
% limitations under the License.
17+
%
18+
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
19+
%
20+
21+
%%-----------------------------------------------------------------------------
22+
%% @doc An implementation of the Erlang/OTP init interface.
23+
%%
24+
%% This module implements a strict subset of the Erlang/OTP init
25+
%% interface.
26+
%% @end
27+
%%-----------------------------------------------------------------------------
28+
-module(init).
29+
30+
-export([
31+
get_argument/1,
32+
get_plain_arguments/0,
33+
notify_when_started/1
34+
]).
35+
36+
%%-----------------------------------------------------------------------------
37+
%% @param Flag flag to get values for
38+
%% @return `error' if no value is associated with provided flag or values in
39+
%% order of the command line
40+
%% @doc Returns values associated with a given command-line user flag.
41+
%% Currently always returns `error' on AtomVM.
42+
%% @end
43+
%%-----------------------------------------------------------------------------
44+
-spec get_argument(Flag :: atom()) -> {ok, [string()]} | error.
45+
get_argument(_Flag) ->
46+
error.
47+
48+
%%-----------------------------------------------------------------------------
49+
%% @return plain command-line arguments as a list of strings.
50+
%% @doc Gets plain command-line arguments.
51+
%% Currently always returns `[]' on AtomVM.
52+
%% @end
53+
%%-----------------------------------------------------------------------------
54+
-spec get_plain_arguments() -> [string()].
55+
get_plain_arguments() ->
56+
[].
57+
58+
%% @private
59+
-spec notify_when_started(Pid :: pid()) -> ok | started.
60+
notify_when_started(_Pid) ->
61+
started.

0 commit comments

Comments
 (0)