#!/usr/bin/env escript
%% -*- erlang -*-

main([BeamDir, TargetFile]) ->
    Modules = [list_to_atom(filename:basename(F, ".beam")) ||
                  F <- filelib:wildcard("*.beam", BeamDir)],
    {ok, {application, Application, Properties}} = io:read(''),
    NewProperties = lists:keyreplace(modules, 1, Properties,
                                     {modules, Modules}),
    file:write_file(
      TargetFile,
      io_lib:format("~p.~n", [{application, Application, NewProperties}])).
