List types
This commit is contained in:
parent
381987475a
commit
ebc870d1ed
6
packup
6
packup
@ -1,5 +1,6 @@
|
||||
#! /usr/bin/env escript
|
||||
|
||||
-mode(compile).
|
||||
|
||||
main(_) ->
|
||||
{ok, BV} = file:read_file("zomp/etc/version.txt"),
|
||||
@ -11,11 +12,8 @@ main(_) ->
|
||||
["install.escript",
|
||||
"install_unix",
|
||||
"uninstall_unix",
|
||||
"install_windows.cmd",
|
||||
"notify.vbs",
|
||||
"README.md",
|
||||
"README.unix",
|
||||
"README.windows",
|
||||
"README.install",
|
||||
"LICENSE",
|
||||
Tar],
|
||||
{ok, Zip} = zip:create(Zip, ZipFiles),
|
||||
|
||||
@ -136,6 +136,18 @@ do(["list", "packages", Realm]) ->
|
||||
do(["list", "versions", PackageName]) ->
|
||||
ok = zx_daemon:connect(),
|
||||
done(zx_local:list_versions(PackageName));
|
||||
do(["list", "gui"]) ->
|
||||
ok = zx_daemon:connect(),
|
||||
done(zx_local:list_type(gui));
|
||||
do(["list", "cli"]) ->
|
||||
ok = zx_daemon:connect(),
|
||||
done(zx_local:list_type(cli));
|
||||
do(["list", "app"]) ->
|
||||
ok = zx_daemon:connect(),
|
||||
done(zx_local:list_type(app));
|
||||
do(["list", "lib"]) ->
|
||||
ok = zx_daemon:connect(),
|
||||
done(zx_local:list_type(lib));
|
||||
do(["latest", PackageString]) ->
|
||||
ok = zx_daemon:connect(),
|
||||
done(zx_local:latest(PackageString));
|
||||
@ -360,10 +372,10 @@ start() ->
|
||||
Error -> done(Error)
|
||||
end;
|
||||
["rundir", Path | _] ->
|
||||
{ok, #{package_id = PackageID}} = zx_lib:read_project_meta(Path),
|
||||
{ok, #{package_id := PackageID}} = zx_lib:read_project_meta(Path),
|
||||
zx_lib:new_logpath(PackageID);
|
||||
["runlocal" | _] ->
|
||||
{ok, #{package_id = PackageID}} = zx_lib:read_project_meta(),
|
||||
{ok, #{package_id := PackageID}} = zx_lib:read_project_meta(),
|
||||
zx_lib:new_logpath(PackageID);
|
||||
_ ->
|
||||
{ok, Version} = zx_lib:string_to_version(os:getenv("ZX_VERSION")),
|
||||
|
||||
@ -294,6 +294,7 @@ dispatch(Socket, ID, Action) ->
|
||||
{list_sysops, R} -> send_query(Socket, 11, R);
|
||||
{fetch, R, N, V} -> fetch(Socket, ID, {R, N, V});
|
||||
{keychain, R, K} -> send_query(Socket, 13, {R, K});
|
||||
{list_type, R, T} -> send_query(Socket, 14, {R, T});
|
||||
Unexpected ->
|
||||
Message = "Received unexpected request action. ID: ~tp, Action: ~200tp",
|
||||
log(warning, Message, [ID, Unexpected])
|
||||
|
||||
@ -147,7 +147,7 @@
|
||||
-export([zomp_mode/0]).
|
||||
-export([pass_meta/3, argv/0,
|
||||
subscribe/1, unsubscribe/1,
|
||||
list/0, list/1, list/2, list/3, latest/1,
|
||||
list/0, list/1, list/2, list/3, list_type/2, latest/1,
|
||||
describe/1, provides/2, list_deps/1, search/2,
|
||||
list_sysops/1,
|
||||
fetch/1, install/1, build/1,
|
||||
@ -446,6 +446,16 @@ list(Realm, Name, Version) ->
|
||||
request({list, Realm, Name, Version}).
|
||||
|
||||
|
||||
-spec list_type(Realm, Type) -> {ok, RequestID}
|
||||
when Realm :: zx:realm(),
|
||||
Type :: zx:package_type(),
|
||||
RequestID :: term().
|
||||
|
||||
list_type(Realm, Type) ->
|
||||
true = zx_lib:valid_lower0_9(Realm),
|
||||
request({list_type, Realm, Type}).
|
||||
|
||||
|
||||
-spec latest(Identifier) -> {ok, RequestID}
|
||||
when Identifier :: zx:package() | zx:package_id(),
|
||||
RequestID :: integer().
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
-license("GPL-3.0").
|
||||
|
||||
-export([initialize/0, set_version/1,
|
||||
list_realms/0, list_packages/1, list_versions/1,
|
||||
list_realms/0, list_packages/1, list_versions/1, list_type/1,
|
||||
latest/1, describe/1, provides/1, search/1,
|
||||
list_sysops/1,
|
||||
set_dep/1, list_deps/0, list_deps/1, drop_dep/1, verup/1, package/1,
|
||||
@ -719,8 +719,6 @@ list_packages(Realm) ->
|
||||
{error, network} -> {error, "Network problem connecting to realm.", 101}
|
||||
end.
|
||||
|
||||
print_package(Realm) -> fun(Name) -> io:format("~ts-~ts~n", [Realm, Name]) end.
|
||||
|
||||
|
||||
-spec list_versions(PackageName :: string()) -> zx:outcome().
|
||||
%% @private
|
||||
@ -746,9 +744,22 @@ list_versions2({Realm, Name, Version}) ->
|
||||
{error, network} -> {error, "Network problem connecting to realm.", 101}
|
||||
end.
|
||||
|
||||
print_version(Version) ->
|
||||
{ok, String} = zx_lib:version_to_string(Version),
|
||||
io:format("~ts~n", [String]).
|
||||
|
||||
-spec list_type(zx:package_type()) -> zx:outcome().
|
||||
|
||||
list_type(Type) ->
|
||||
Realms = zx_lib:list_realms(),
|
||||
MakeRequest =
|
||||
fun(Realm) ->
|
||||
{ok, ID} = zx_daemon:list_type(Realm, Type),
|
||||
ID
|
||||
end,
|
||||
Index = [{MakeRequest(R), R} || R <- Realms],
|
||||
IDs = [element(1, I) || I <- Index],
|
||||
case zx_daemon:wait_results(IDs) of
|
||||
{ok, Results} -> print_multirealm(lists:sort(Index), lists:sort(Results));
|
||||
Error -> Error
|
||||
end.
|
||||
|
||||
|
||||
-spec latest(PackageString :: string()) -> zx:outcome().
|
||||
@ -819,20 +830,10 @@ provides(Module) ->
|
||||
Index = [{MakeRequest(R), R} || R <- Realms],
|
||||
IDs = [element(1, I) || I <- Index],
|
||||
case zx_daemon:wait_results(IDs) of
|
||||
{ok, Results} -> provides2(lists:sort(Index), lists:sort(Results));
|
||||
{ok, Results} -> print_multirealm(lists:sort(Index), lists:sort(Results));
|
||||
Error -> Error
|
||||
end.
|
||||
|
||||
provides2([{ID, Realm} | Index], [{ID, {ok, Packages}} | Results]) ->
|
||||
FormID = fun({Name, Version}) -> {Realm, Name, Version} end,
|
||||
ok = lists:foreach(fun print_packages/1, lists:map(FormID, lists:sort(Packages))),
|
||||
provides2(Index, Results);
|
||||
provides2([{ID, Realm} | Index], [{ID, Error} | Results]) ->
|
||||
ok = tell(warning, "Received weird result from ~p: ~p", [Realm, Error]),
|
||||
provides2(Index, Results);
|
||||
provides2([], []) ->
|
||||
ok.
|
||||
|
||||
|
||||
search(String) ->
|
||||
Realms = zx_lib:list_realms(),
|
||||
@ -860,11 +861,31 @@ search2([], []) ->
|
||||
ok.
|
||||
|
||||
|
||||
print_package(Realm) ->
|
||||
fun(Name) -> io:format("~ts-~ts~n", [Realm, Name]) end.
|
||||
|
||||
|
||||
print_multirealm([{ID, Realm} | Index], [{ID, {ok, Packages}} | Results]) ->
|
||||
FormID = fun({Name, Version}) -> {Realm, Name, Version} end,
|
||||
ok = lists:foreach(fun print_packages/1, lists:map(FormID, lists:sort(Packages))),
|
||||
print_multirealm(Index, Results);
|
||||
print_multirealm([{ID, Realm} | Index], [{ID, Error} | Results]) ->
|
||||
ok = tell(warning, "Received weird result from ~p: ~p", [Realm, Error]),
|
||||
print_multirealm(Index, Results);
|
||||
print_multirealm([], []) ->
|
||||
ok.
|
||||
|
||||
|
||||
print_packages(PackageID) ->
|
||||
{ok, PackageString} = zx_lib:package_string(PackageID),
|
||||
io:format("~ts~n", [PackageString]).
|
||||
|
||||
|
||||
print_version(Version) ->
|
||||
{ok, String} = zx_lib:version_to_string(Version),
|
||||
io:format("~ts~n", [String]).
|
||||
|
||||
|
||||
-spec list_sysops(zx:realm()) -> zx:outcome().
|
||||
|
||||
list_sysops(Realm) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user