WIP: Make external program interface libe in 'zx', add desktop integration
This commit is contained in:
parent
6f5a829d43
commit
ea66d1c191
@ -131,6 +131,9 @@ do(["--version"]) ->
|
||||
do(["run", PackageString | ArgV]) ->
|
||||
ok = zx_daemon:connect(),
|
||||
not_done(run(PackageString, ArgV));
|
||||
do(["integrate", "desktop", PackageString]) ->
|
||||
ok = zx_daemon:connect(),
|
||||
done(zx_local:integrate(PackageString));
|
||||
do(["list", "realms"]) ->
|
||||
done(zx_local:list_realms());
|
||||
do(["list", "packages", Realm]) ->
|
||||
@ -590,12 +593,11 @@ list_type(Realm, Type) ->
|
||||
zx_daemon:wait_result(ID).
|
||||
|
||||
|
||||
-spec list_type_ar(Type) -> Outcome
|
||||
-spec list_type_ar(Type) -> Result
|
||||
when Type :: package_type(),
|
||||
Outcome :: {ok, [Result]}
|
||||
Result :: {ok, [package_id()]}
|
||||
| {error, Unexpected, [Result]}
|
||||
| {error, Reason},
|
||||
Result :: {id(), [package_id()]},
|
||||
Unexpected :: {unexpected, {result, id(), term()}},
|
||||
Reason :: bad_realm
|
||||
| bad_package
|
||||
@ -621,12 +623,51 @@ list_type_ar(Targets) ->
|
||||
Error -> Error
|
||||
end.
|
||||
|
||||
scrub_errors([{ID, _} | Index], [{ID, {ok, PackageIDs}} | Results], Acc) ->
|
||||
scrub_errors(Index, Results, [PackageIDs | Acc]);
|
||||
scrub_errors([{ID, Realm} | Index], [{ID, Error} | Results], Acc) ->
|
||||
ok = tell(warning, "Received weird result from realm ~tp: ~tp", [Realm, Error]),
|
||||
scrub_errors(Index, Results, Acc);
|
||||
scrub_errors([], [], Acc) ->
|
||||
lists:append(Acc).
|
||||
|
||||
|
||||
-spec describe(Target) -> Result
|
||||
-spec describe(package_id()) -> Result
|
||||
when Target :: package_id(),
|
||||
Result ::
|
||||
Result :: {ok, description()}
|
||||
| {error, Reason},
|
||||
Reason :: bad_realm
|
||||
| bad_package
|
||||
| bad_version
|
||||
| timeout
|
||||
| network.
|
||||
|
||||
describe(PackageID) ->
|
||||
{ok, ID} = zx_daemon:describe(PackageID),
|
||||
zx_daemon:wait_result(ID).
|
||||
|
||||
|
||||
-spec describe_plural([package_id()]) -> Result
|
||||
when Result :: {ok, [description()]}
|
||||
| {error, Unexpected, [Result]}
|
||||
| {error, Reason},
|
||||
Unexpected :: {unexpected, {result, id(), term()}},
|
||||
Reason :: bad_realm
|
||||
| bad_package
|
||||
| bad_version
|
||||
| timeout
|
||||
| network
|
||||
| {unexpected, Message :: string()}.
|
||||
|
||||
describe_plural(PackageIDs) ->odescribe(PackageIDs) ->
|
||||
Describe =
|
||||
fun(PackageID) ->
|
||||
{ok, ID} = zx_daemon:describe(PackageID),
|
||||
ID
|
||||
end,
|
||||
IDs = lists:map(Describe, PackageIDs),
|
||||
{ok, Descriptions} = zx_daemon:wait_results(IDs),
|
||||
{ok, [Description || {_, {ok, Description}} <- Descriptions]}.
|
||||
|
||||
|
||||
%%% Execution of application
|
||||
@ -947,6 +988,7 @@ usage_header() ->
|
||||
usage_user() ->
|
||||
"User Actions:~n"
|
||||
" zx run PackageID [Args]~n"
|
||||
" zx integrate desktop PackageID~n"
|
||||
" zx list realms~n"
|
||||
" zx list packages Realm~n"
|
||||
" zx list versions PackageID~n"
|
||||
@ -958,7 +1000,8 @@ usage_user() ->
|
||||
" zx import realm RealmFile~n"
|
||||
" zx drop realm Realm~n"
|
||||
" zx add mirror [Address [Port]]~n"
|
||||
" zx drop mirror [Address [Port]]~n~n".
|
||||
" zx drop mirror [Address [Port]]~n~n"
|
||||
" zx --version~n~n".
|
||||
|
||||
usage_dev() ->
|
||||
"Developer/Packager/Maintainer Actions:~n"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user