% SPDX-FileCopyrightText: 2026 Dipl. Phys. Peer Stritzinger GmbH
%
% SPDX-License-Identifier: Apache-2.0
-module(rebar_calzone_record).
-export([record/1]).
%--- Includes ------------------------------------------------------------------
%--- Macros --------------------------------------------------------------------
%--- API -----------------------------------------------------------------------
-spec record(map()) -> ok | no_return().
record(#{mode := escript} = Options) ->
#{calzone_dir := CalzoneDir,
dir := EscriptDir,
name := EscriptName} = Options,
EscriptPath = filename:join([EscriptDir, EscriptName]),
case filelib:is_file(EscriptPath) of
false ->
rebar_api:abort("Unable to find escript at path: ~p",
[EscriptPath]);
true ->
rebar_calzone_utils:run_escript(EscriptPath, CalzoneDir)
end;
record(#{mode := release}) ->
rebar_api:abort("Release mode not supported").
%--- Private -------------------------------------------------------------------