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]) ->
|
do(["run", PackageString | ArgV]) ->
|
||||||
ok = zx_daemon:connect(),
|
ok = zx_daemon:connect(),
|
||||||
not_done(run(PackageString, ArgV));
|
not_done(run(PackageString, ArgV));
|
||||||
|
do(["integrate", "desktop", PackageString]) ->
|
||||||
|
ok = zx_daemon:connect(),
|
||||||
|
done(zx_local:integrate(PackageString));
|
||||||
do(["list", "realms"]) ->
|
do(["list", "realms"]) ->
|
||||||
done(zx_local:list_realms());
|
done(zx_local:list_realms());
|
||||||
do(["list", "packages", Realm]) ->
|
do(["list", "packages", Realm]) ->
|
||||||
@ -590,12 +593,11 @@ list_type(Realm, Type) ->
|
|||||||
zx_daemon:wait_result(ID).
|
zx_daemon:wait_result(ID).
|
||||||
|
|
||||||
|
|
||||||
-spec list_type_ar(Type) -> Outcome
|
-spec list_type_ar(Type) -> Result
|
||||||
when Type :: package_type(),
|
when Type :: package_type(),
|
||||||
Outcome :: {ok, [Result]}
|
Result :: {ok, [package_id()]}
|
||||||
| {error, Unexpected, [Result]}
|
| {error, Unexpected, [Result]}
|
||||||
| {error, Reason},
|
| {error, Reason},
|
||||||
Result :: {id(), [package_id()]},
|
|
||||||
Unexpected :: {unexpected, {result, id(), term()}},
|
Unexpected :: {unexpected, {result, id(), term()}},
|
||||||
Reason :: bad_realm
|
Reason :: bad_realm
|
||||||
| bad_package
|
| bad_package
|
||||||
@ -621,12 +623,51 @@ list_type_ar(Targets) ->
|
|||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
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(),
|
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
|
%%% Execution of application
|
||||||
@ -947,6 +988,7 @@ usage_header() ->
|
|||||||
usage_user() ->
|
usage_user() ->
|
||||||
"User Actions:~n"
|
"User Actions:~n"
|
||||||
" zx run PackageID [Args]~n"
|
" zx run PackageID [Args]~n"
|
||||||
|
" zx integrate desktop PackageID~n"
|
||||||
" zx list realms~n"
|
" zx list realms~n"
|
||||||
" zx list packages Realm~n"
|
" zx list packages Realm~n"
|
||||||
" zx list versions PackageID~n"
|
" zx list versions PackageID~n"
|
||||||
@ -958,7 +1000,8 @@ usage_user() ->
|
|||||||
" zx import realm RealmFile~n"
|
" zx import realm RealmFile~n"
|
||||||
" zx drop realm Realm~n"
|
" zx drop realm Realm~n"
|
||||||
" zx add mirror [Address [Port]]~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() ->
|
usage_dev() ->
|
||||||
"Developer/Packager/Maintainer Actions:~n"
|
"Developer/Packager/Maintainer Actions:~n"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user