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,
[{description,"An Erlang development tool and Zomp user client"},
{vsn,"0.7.2"},
{vsn,"0.8.0"},
{applications,[stdlib,kernel]},
{modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key,
zx_lib,zx_local,zx_net,zx_peer,zx_peer_man,

View File

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

View File

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

View File

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

View File

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

View File

@ -138,7 +138,7 @@
%%% @end
-module(zx_daemon).
-vsn("0.7.2").
-vsn("0.8.0").
-behavior(gen_server).
-author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>").

View File

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

View File

@ -10,7 +10,7 @@
%%% @end
-module(zx_lib).
-vsn("0.7.2").
-vsn("0.8.0").
-author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0").

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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