Expand daemon public interface; minor fix.

Added:
- zx_daemon:dir/1
- zx_daemon:dirv/1
- zx_daemon:argv/0
- zx_daemon:meta/0

Fixed:
- `zx remove mirror`
This commit is contained in:
Craig Everett 2020-06-10 15:41:39 +09:00
parent 107a3e466b
commit fac2aaf6b6
49 changed files with 72 additions and 41 deletions

View File

@ -1 +1 @@
0.10.6 0.10.7

View File

@ -1,6 +1,6 @@
{application,zx, {application,zx,
[{description,"An Erlang development tool and Zomp user client"}, [{description,"An Erlang development tool and Zomp user client"},
{vsn,"0.10.6"}, {vsn,"0.10.7"},
{applications,[stdlib,kernel]}, {applications,[stdlib,kernel]},
{modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key, {modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key,
zx_lib,zx_local,zx_net,zx_peer,zx_peer_man, zx_lib,zx_local,zx_net,zx_peer,zx_peer_man,

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -24,7 +24,7 @@
%%% @end %%% @end
-module(zx). -module(zx).
-vsn("0.10.6"). -vsn("0.10.7").
-behavior(application). -behavior(application).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
@ -47,7 +47,7 @@
user_id/0, user_name/0, contact_info/0, user_data/0, user_id/0, user_name/0, contact_info/0, user_data/0,
lower0_9/0, label/0, lower0_9/0, label/0,
ss_tag/0, search_tag/0, description/0, package_type/0, ss_tag/0, search_tag/0, description/0, package_type/0,
outcome/0]). outcome/0, core_dir/0]).
-include("zx_logger.hrl"). -include("zx_logger.hrl").
@ -102,6 +102,9 @@
| {error, Code :: non_neg_integer()} | {error, Code :: non_neg_integer()}
| {error, Info :: string(), Code :: non_neg_integer()}. | {error, Info :: string(), Code :: non_neg_integer()}.
-type core_dir() :: etc | var | tmp | log | key | zsp | lib.
%%% Command Dispatch %%% Command Dispatch

View File

@ -9,7 +9,7 @@
%%% @end %%% @end
-module(zx_auth). -module(zx_auth).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -7,7 +7,7 @@
%%% @end %%% @end
-module(zx_conn). -module(zx_conn).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_conn_sup). -module(zx_conn_sup).
-vsn("0.10.6"). -vsn("0.10.7").
-behavior(supervisor). -behavior(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -138,16 +138,16 @@
%%% @end %%% @end
-module(zx_daemon). -module(zx_daemon).
-vsn("0.10.6"). -vsn("0.10.7").
-behavior(gen_server). -behavior(gen_server).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").
-export([get_home/0]). -export([get_home/0, dir/1, dirv/1, meta/0, argv/0]).
-export([zomp_mode/0]). -export([zomp_mode/0]).
-export([pass_meta/3, argv/0, -export([pass_meta/3,
subscribe/1, unsubscribe/1, subscribe/1, unsubscribe/1,
list/0, list/1, list/2, list/3, list_type/1, latest/1, list/0, list/1, list/2, list/3, list_type/1, latest/1,
describe/1, provides/2, list_deps/1, search/1, describe/1, provides/2, list_deps/1, search/1,
@ -179,7 +179,7 @@
%%% Type Definitions %%% Type Definitions
-record(s, -record(s,
{meta = none :: none | zx:package_meta(), {meta = none :: none | zx_zsp:meta(),
home = none :: none | file:filename(), home = none :: none | file:filename(),
argv = [] :: [string()], argv = [] :: [string()],
conf = load_conf() :: conf(), conf = load_conf() :: conf(),
@ -334,6 +334,32 @@ get_home() ->
gen_server:call(?MODULE, get_home). gen_server:call(?MODULE, get_home).
-spec dir(zx:core_dir() | home) -> file:filename().
dir(home) ->
get_home();
dir(Type) ->
gen_server:call(?MODULE, {dir, Type}).
-spec dirv(zx:core_dir()) -> file:filename().
dirv(Type) ->
gen_server:call(?MODULE, {dirv, Type}).
-spec meta() -> zx_zsp:meta().
meta() ->
gen_server:call(?MODULE, meta).
-spec argv() -> [string()].
argv() ->
gen_server:call(?MODULE, argv).
%%% Zomp Internal Interface %%% Zomp Internal Interface
-spec zomp_mode() -> ok. -spec zomp_mode() -> ok.
@ -358,12 +384,6 @@ pass_meta(Meta, Dir, ArgV) ->
gen_server:cast(?MODULE, {pass_meta, Meta, Dir, ArgV}). gen_server:cast(?MODULE, {pass_meta, Meta, Dir, ArgV}).
-spec argv() -> [string()].
argv() ->
gen_server:call(?MODULE, argv).
-spec subscribe(Package) -> ok -spec subscribe(Package) -> ok
when Package :: zx:package(). when Package :: zx:package().
%% @doc %% @doc
@ -811,10 +831,20 @@ idle() ->
%% @private %% @private
%% gen_server callback for OTP calls %% gen_server callback for OTP calls
handle_call(argv, _, State = #s{argv = ArgV}) ->
{reply, ArgV, State};
handle_call(get_home, _, State = #s{home = Home}) -> handle_call(get_home, _, State = #s{home = Home}) ->
{reply, Home, State}; {reply, Home, State};
handle_call({dir, Type}, _, State = #s{meta = Meta}) ->
{Realm, Name, _} = maps:get(package_id, Meta),
Result = zx_lib:ppath(Type, {Realm, Name}),
{reply, Result, State};
handle_call({dirv, Type}, _, State = #s{meta = Meta}) ->
PackageID = maps:get(package_id, Meta),
Result = zx_lib:ppath(Type, PackageID),
{reply, Result, State};
handle_call(meta, _, State = #s{meta = Meta}) ->
{reply, Meta, State};
handle_call(argv, _, State = #s{argv = ArgV}) ->
{reply, ArgV, State};
handle_call({request, list}, _, State = #s{cx = CX}) -> handle_call({request, list}, _, State = #s{cx = CX}) ->
Realms = cx_realms(CX), Realms = cx_realms(CX),
{reply, {ok, Realms}, State}; {reply, {ok, Realms}, State};

View File

@ -8,7 +8,7 @@
%%% @end %%% @end
-module(zx_key). -module(zx_key).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -10,7 +10,7 @@
%%% @end %%% @end
-module(zx_lib). -module(zx_lib).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").
@ -39,8 +39,6 @@
-include("zx_logger.hrl"). -include("zx_logger.hrl").
-type core_dir() :: etc | var | tmp | log | key | zsp | lib.
%%% Functions %%% Functions
@ -76,7 +74,7 @@ find_zomp_dir() ->
end. end.
-spec path(core_dir()) -> file:filename(). -spec path(zx:core_dir()) -> file:filename().
%% @private %% @private
%% Return the top-level path of the given type in the Zomp/ZX system. %% Return the top-level path of the given type in the Zomp/ZX system.
@ -89,7 +87,7 @@ path(zsp) -> filename:join(zomp_dir(), "zsp");
path(lib) -> filename:join(zomp_dir(), "lib"). path(lib) -> filename:join(zomp_dir(), "lib").
-spec path(core_dir(), zx:realm()) -> file:filename(). -spec path(zx:core_dir(), zx:realm()) -> file:filename().
%% @private %% @private
%% Return the realm-level path of the given type in the Zomp/ZX system. %% Return the realm-level path of the given type in the Zomp/ZX system.
@ -97,7 +95,7 @@ path(Type, Realm) ->
filename:join(path(Type), Realm). filename:join(path(Type), Realm).
-spec path(core_dir(), zx:realm(), zx:name()) -> file:filename(). -spec path(zx:core_dir(), zx:realm(), zx:name()) -> file:filename().
%% @private %% @private
%% Return the package-level path of the given type in the Zomp/ZX system. %% Return the package-level path of the given type in the Zomp/ZX system.
@ -105,7 +103,7 @@ path(Type, Realm, Name) ->
filename:join([path(Type), Realm, Name]). filename:join([path(Type), Realm, Name]).
-spec path(core_dir(), zx:realm(), zx:name(), zx:version()) -> file:filename(). -spec path(zx:core_dir(), zx:realm(), zx:name(), zx:version()) -> file:filename().
%% @private %% @private
%% Return the version-specific level path of the given type in the Zomp/ZX system. %% Return the version-specific level path of the given type in the Zomp/ZX system.
@ -114,7 +112,7 @@ path(Type, Realm, Name, Version) ->
filename:join([path(Type), Realm, Name, VersionString]). filename:join([path(Type), Realm, Name, VersionString]).
-spec ppath(core_dir(), zx:package_id()) -> file:filename(). -spec ppath(zx:core_dir(), zx:package_id()) -> file:filename().
%% @private %% @private
%% An alias for path/3,4, but more convenient when needing a path from a closed %% An alias for path/3,4, but more convenient when needing a path from a closed
%% package_id(). %% package_id().

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
-module(zx_local). -module(zx_local).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").
@ -2701,7 +2701,7 @@ add_mirror(Address, PortString) ->
-spec drop_mirror() -> ok. -spec drop_mirror() -> ok.
drop_mirror() -> drop_mirror() ->
case zx_daemon:list_mirrors() of case zx_daemon:conf(mirrors) of
{ok, []} -> {ok, []} ->
io:format("No mirrors to drop!~n"); io:format("No mirrors to drop!~n");
{ok, Current} -> {ok, Current} ->

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_net). -module(zx_net).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -8,7 +8,7 @@
%%% @end %%% @end
-module(zx_peer). -module(zx_peer).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -9,7 +9,7 @@
%%% @end %%% @end
-module(zx_peer_man). -module(zx_peer_man).
-vsn("0.10.6"). -vsn("0.10.7").
-behavior(gen_server). -behavior(gen_server).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
-module(zx_peer_sup). -module(zx_peer_sup).
-vsn("0.10.6"). -vsn("0.10.7").
-behaviour(supervisor). -behaviour(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -10,7 +10,7 @@
%%% @end %%% @end
-module(zx_peers). -module(zx_peers).
-vsn("0.10.6"). -vsn("0.10.7").
-behavior(supervisor). -behavior(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_proxy). -module(zx_proxy).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_sup). -module(zx_sup).
-vsn("0.10.6"). -vsn("0.10.7").
-behavior(supervisor). -behavior(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
-module(zx_tty). -module(zx_tty).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_userconf). -module(zx_userconf).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -7,7 +7,7 @@
%%% @end %%% @end
-module(zx_zsp). -module(zx_zsp).
-vsn("0.10.6"). -vsn("0.10.7").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -9,7 +9,7 @@
{license,"MIT"}. {license,"MIT"}.
{modules,[]}. {modules,[]}.
{name,"zx"}. {name,"zx"}.
{package_id,{"otpr","zx",{0,10,6}}}. {package_id,{"otpr","zx",{0,10,7}}}.
{prefix,"zx_"}. {prefix,"zx_"}.
{repo_url,"https://gitlab.com/zxq9/zx"}. {repo_url,"https://gitlab.com/zxq9/zx"}.
{tags,["tools","package manager","erlang"]}. {tags,["tools","package manager","erlang"]}.