Clean up external program API.

This commit is contained in:
Craig Everett 2020-01-10 20:56:48 +09:00
parent f1c97bcb88
commit 894edbe39e
48 changed files with 38 additions and 41 deletions

View File

@ -1 +1 @@
0.7.2 0.8.0

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.7.2"}, {vsn,"0.8.0"},
{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

@ -24,7 +24,7 @@
%%% @end %%% @end
-module(zx). -module(zx).
-vsn("0.7.2"). -vsn("0.8.0").
-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>").
@ -35,7 +35,7 @@
-export([run/2, not_done/1, done/1, -export([run/2, not_done/1, done/1,
subscribe/1, unsubscribe/0, subscribe/1, unsubscribe/0,
list/0, list/1, list/2, list/3, latest/1, list/0, list/1, list/2, list/3, latest/1,
list_type/2, list_type_ar/2, describe/1, describe_plural/1, list_type/2, list_type_ar/1, describe/1, describe_plural/1,
stop/0, silent_stop/0]). stop/0, silent_stop/0]).
-export([start/2, stop/1]). -export([start/2, stop/1]).
@ -598,7 +598,7 @@ list_type(Realm, Type) ->
Result :: {ok, [package_id()]} Result :: {ok, [package_id()]}
| {error, Unexpected, [Result]} | {error, Unexpected, [Result]}
| {error, Reason}, | {error, Reason},
Unexpected :: {unexpected, {result, id(), term()}}, Unexpected :: {unexpected, {result, zx_daemon:id(), term()}},
Reason :: bad_realm Reason :: bad_realm
| bad_package | bad_package
| bad_version | bad_version
@ -609,7 +609,7 @@ list_type(Realm, Type) ->
%% List all packages from all realms that are of `Type'. %% List all packages from all realms that are of `Type'.
%% The "_ar" suffix to this function is short for "all realms". %% The "_ar" suffix to this function is short for "all realms".
list_type_ar(Targets) -> list_type_ar(Type) ->
Realms = zx_lib:list_realms(), Realms = zx_lib:list_realms(),
MakeRequest = MakeRequest =
fun(Realm) -> fun(Realm) ->
@ -633,8 +633,7 @@ scrub_errors([], [], Acc) ->
-spec describe(package_id()) -> Result -spec describe(package_id()) -> Result
when Target :: package_id(), when Result :: {ok, description()}
Result :: {ok, description()}
| {error, Reason}, | {error, Reason},
Reason :: bad_realm Reason :: bad_realm
| bad_package | bad_package
@ -651,7 +650,7 @@ describe(PackageID) ->
when Result :: {ok, [description()]} when Result :: {ok, [description()]}
| {error, Unexpected, [Result]} | {error, Unexpected, [Result]}
| {error, Reason}, | {error, Reason},
Unexpected :: {unexpected, {result, id(), term()}}, Unexpected :: {unexpected, {result, zx_daemon:id(), term()}},
Reason :: bad_realm Reason :: bad_realm
| bad_package | bad_package
| bad_version | bad_version
@ -659,7 +658,7 @@ describe(PackageID) ->
| network | network
| {unexpected, Message :: string()}. | {unexpected, Message :: string()}.
describe_plural(PackageIDs) ->odescribe(PackageIDs) -> describe_plural(PackageIDs) ->
Describe = Describe =
fun(PackageID) -> fun(PackageID) ->
{ok, ID} = zx_daemon:describe(PackageID), {ok, ID} = zx_daemon:describe(PackageID),

View File

@ -9,7 +9,7 @@
%%% @end %%% @end
-module(zx_auth). -module(zx_auth).
-vsn("0.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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,7 +138,7 @@
%%% @end %%% @end
-module(zx_daemon). -module(zx_daemon).
-vsn("0.7.2"). -vsn("0.8.0").
-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

@ -8,7 +8,7 @@
%%% @end %%% @end
-module(zx_key). -module(zx_key).
-vsn("0.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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

@ -6,7 +6,7 @@
%%% @end %%% @end
-module(zx_local). -module(zx_local).
-vsn("0.7.2"). -vsn("0.8.0").
-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").
@ -1883,20 +1883,23 @@ store_realm(#realm_init{realm = Realm,
addr = Addr, addr = Addr,
port = Port, port = Port,
url = URL, url = URL,
sysop = #user_data{username = UserName, sysop = U = #user_data{username = UserName,
realname = RealName, realname = RealName,
keys = [KeyName], contact_info = [ContactInfo]}}) ->
contact_info = [ContactInfo]}}) ->
ok = make_realm_dirs(Realm), ok = make_realm_dirs(Realm),
RealmConfPath = filename:join(zx_lib:path(etc, Realm), "realm.conf"),
ok = file:write_file(RealmConfPath, "Placeholder realm file."),
{ok, KeyHash} = zx_key:generate_rsa({Realm, UserName}),
NewU = U#user_data{keys = [KeyHash]},
RealmConf = RealmConf =
[{realm, Realm}, [{realm, Realm},
{prime, {Addr, Port}}, {prime, {Addr, Port}},
{sysop, {UserName, RealName, ContactInfo}}, {sysop, {UserName, RealName, ContactInfo}},
{key, KeyName}, {key, KeyHash},
{url, URL}, {url, URL},
{timestamp, calendar:universal_time()}], {timestamp, calendar:universal_time()}],
RealmConfPath = filename:join(zx_lib:path(etc, Realm), "realm.conf"),
ok = zx_lib:write_terms(RealmConfPath, RealmConf), ok = zx_lib:write_terms(RealmConfPath, RealmConf),
ok = store_user(NewU),
ok = export_realm(Realm), ok = export_realm(Realm),
ok = export_user(zpuf, Realm, UserName), ok = export_user(zpuf, Realm, UserName),
ZPUF = Realm ++ "-" ++ UserName ++ ".zpuf", ZPUF = Realm ++ "-" ++ UserName ++ ".zpuf",
@ -2064,8 +2067,7 @@ create_sysop(U = #user_data{realname = none}) ->
create_sysop(U#user_data{realname = ask_realname()}); create_sysop(U#user_data{realname = ask_realname()});
create_sysop(U = #user_data{contact_info = none}) -> create_sysop(U = #user_data{contact_info = none}) ->
create_sysop(U#user_data{contact_info = [{"email", ask_email()}]}); create_sysop(U#user_data{contact_info = [{"email", ask_email()}]});
create_sysop(U = #user_data{realm = Realm, create_sysop(U = #user_data{username = UserName,
username = UserName,
realname = RealName, realname = RealName,
contact_info = [{"email", Email}]}) -> contact_info = [{"email", Email}]}) ->
Instructions = Instructions =
@ -2080,11 +2082,7 @@ create_sysop(U = #user_data{realm = Realm,
"1" -> create_sysop(U#user_data{username = none}); "1" -> create_sysop(U#user_data{username = none});
"2" -> create_sysop(U#user_data{realname = none}); "2" -> create_sysop(U#user_data{realname = none});
"3" -> create_sysop(U#user_data{contact_info = none}); "3" -> create_sysop(U#user_data{contact_info = none});
"" -> "" -> U;
{ok, KeyHash} = zx_key:generate_rsa(Realm),
NewU = U#user_data{keys = [KeyHash]},
ok = store_user(NewU),
NewU;
_ -> _ ->
ok = zx_tty:derp(), ok = zx_tty:derp(),
create_sysop(U) create_sysop(U)

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_net). -module(zx_net).
-vsn("0.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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.7.2"). -vsn("0.8.0").
-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,7,2}}}. {package_id,{"otpr","zx",{0,8,0}}}.
{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"]}.