Skip to content

Commit

Permalink
Consider dest_file parameter for both .config and vm.args files
Browse files Browse the repository at this point in the history
The `dest_file` parameter can now be supplied as well for standalone generation of `vm.args` files,
this allows generation of multiple `vm.args` type files that can be include from one another through
the `-args_file` parameter.
  • Loading branch information
lrascao committed Nov 4, 2020
1 parent 39beaf5 commit 13ebade
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cuttlefish_escript.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cli_options() ->
{help, $h, "help", undefined, "Print this usage page"},
{etc_dir, $e, "etc_dir", {string, "/etc"}, "etc dir"},
{dest_dir, $d, "dest_dir", string, "specifies the directory to write the config file to"},
{dest_file, $f, "dest_file", {string, "app"}, "the file name to write"},
{dest_file, $f, "dest_file", string, "the file name to write"},
{schema_dir, $s, "schema_dir", string, "a directory containing .schema files"},
%% one or more schema file paths
{schema_file, $i, "schema_file", string, "individual schema file, will be processed in command line order, after -s"},
Expand Down Expand Up @@ -357,13 +357,14 @@ engage_cuttlefish(ParsedArgs) ->
Path -> Path
end,

DestinationFilename = filename_maker(proplists:get_value(dest_file, ParsedArgs), "config"),
DestinationFilename = filename_maker(proplists:get_value(dest_file, ParsedArgs, "app"), "config"),
Destination = filename:join(AbsPath, DestinationFilename),

DestinationVMArgsFilename = filename_maker("vm", "args"),
DestinationVMArgsFilename = filename_maker(proplists:get_value(dest_file, ParsedArgs, "vm"), "args"),
DestinationVMArgs = filename:join(AbsPath, DestinationVMArgsFilename),

lager:debug("Generating config in: ~p", [Destination]),
lager:debug("Generating vm.args in: ~p", [DestinationVMArgs]),

Schema = load_schema(ParsedArgs),
Conf = load_conf(ParsedArgs),
Expand Down
6 changes: 6 additions & 0 deletions test/cuttlefish_escript_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,10 @@ silent_test() ->
?assertPrinted("", [exact])
end).

vm_args_test() ->
?capturing(begin
cuttlefish_escript:main(["--schema_file", "priv/erlang_vm.schema", "--conf_file", "test/riak.conf", "--etc_dir", "etc", "--dest_file", "vm.generated.args", "--allow_extra", "--silent"]),
?assertPrinted("", [exact])
end).

-endif.

0 comments on commit 13ebade

Please sign in to comment.