Changeset

168:75e8ca131178

Update to handle Prosody module namespacing This enables installation methods other than squish, such as luarocks
author Kim Alvefur <zash@zash.se>
date Fri, 26 May 2023 22:39:38 +0200
parents 167:57bb6e03d239
children 169:4e67d34c1298
files clix.lua clix/adhoc.lua clix/archive.lua clix/avatar.lua clix/export.lua clix/moderate.lua clix/publish_atom.lua clix/raw.lua clix/roster.lua clix/send.lua clix/vcard.lua
diffstat 11 files changed, 35 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/clix.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix.lua	Fri May 26 22:39:38 2023 +0200
@@ -12,14 +12,16 @@
 	a = "account", p = "password", r = "resource", o = "presence", c = "chatroom", i = "interactive",
     f = "file" }
 
+
+local commands = "adhoc archive avatar bounce export mirror moderate ping\
+presence publish_atom raw receive roster send sendfile sendfilecontent vcard\
+version watch_pep"
 if #arg < 1 then
 	print("Command Line XMPP, available commands:");
-	for module in pairs(package.preload) do
-		if module:match("^clix%.") then
-			local m = require(module);
-			io.write("\t", module:gsub("^clix%.", ""), ": ");
-			m({ short_help = true }, {});
-		end
+	for command in commands:gmatch("%S+") do
+		local m = require("clix."..command);
+		io.write("\t", command, ": ");
+		m({ short_help = true }, {});
 	end
 	return 0;
 end
@@ -117,7 +119,7 @@
 
 	local clientkey, serverkey = account.clientkey, account.serverkey;
 	if clientkey and serverkey then
-		local hex = require "util.hex";
+		local hex = require "prosody.util.hex";
 		clientkey = hex.from(clientkey);
 		serverkey = hex.from(serverkey);
 	elseif clientkey or serverkey then
--- a/clix/adhoc.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/adhoc.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,4 +1,4 @@
-local dataforms = require "util.dataforms";
+local dataforms = require "prosody.util.dataforms";
 
 -- TODO Cleanup, commit
 return function (opts, arg)
--- a/clix/archive.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/archive.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,6 +1,6 @@
-local jid_split = require"util.jid".split;
-local bare_jid = require"util.jid".bare;
-local datetime = require"util.datetime";
+local jid_split = require"prosody.util.jid".split;
+local bare_jid = require"prosody.util.jid".bare;
+local datetime = require"prosody.util.datetime";
 return function (opts, arg)
 	if opts.short_help then
 		print("Fetch archived messages");
@@ -42,8 +42,8 @@
 		print"";
 	end
 	if opts.format == "raw" then
-		local st = require"util.stanza";
-		local datetime = require"util.datetime".datetime;
+		local st = require"prosody.util.stanza";
+		local datetime = require"prosody.util.datetime".datetime;
 		function print_message(i)
 		print(st.stanza("forwarded",{xmlns="urn:xmpp:forward:0"})
 			:tag("delay", {xmlns="urn:xmpp:delay", stamp=datetime(i.stamp)}):up()
--- a/clix/avatar.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/avatar.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,7 +1,7 @@
-local b64 = require"util.encodings".base64.encode;
-local unb64 = require"util.encodings".base64.decode;
-local st = require "util.stanza";
-local sha1 = require "util.hashes".sha1;
+local b64 = require"prosody.util.encodings".base64.encode;
+local unb64 = require"prosody.util.encodings".base64.decode;
+local st = require "prosody.util.stanza";
+local sha1 = require "prosody.util.hashes".sha1;
 
 return function(opts, arg)
 	if opts.short_help then
--- a/clix/export.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/export.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,7 +1,7 @@
 local verse = require "verse";
 short_opts.i = "interactive";
-local split_jid = require "util.jid".split;
-local timer = require "util.timer";
+local split_jid = require "prosody.util.jid".split;
+local timer = require "prosody.util.timer";
 
 local xmlns_pie = "urn:xmpp:pie:0";
 local xmlns_nodes = {
--- a/clix/moderate.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/moderate.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,7 +1,7 @@
-local jid_split = require"util.jid".split;
-local datetime = require "util.datetime";
-local st = require "util.stanza";
-local uuid = require"util.uuid".generate;
+local jid_split = require"prosody.util.jid".split;
+local datetime = require "prosody.util.datetime";
+local st = require "prosody.util.stanza";
+local uuid = require"prosody.util.uuid".generate;
 
 return function(opts, arg)
 	if opts.help then
--- a/clix/publish_atom.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/publish_atom.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,6 +1,6 @@
 local verse = require "verse";
-local new_uuid = require "util.uuid".generate;
-local datetime = require "util.datetime".datetime;
+local new_uuid = require "prosody.util.uuid".generate;
+local datetime = require "prosody.util.datetime".datetime;
 
 local xmlns_atom = "http://www.w3.org/2005/Atom";
 local xmlns_activitystreams = "http://activitystrea.ms/spec/1.0/";
--- a/clix/raw.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/raw.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,6 +1,6 @@
 local verse = require "verse";
-local envload = require "util.envload".envload;
-local xml = require "util.xml";
+local envload = require "prosody.util.envload".envload;
+local xml = require "prosody.util.xml";
 short_opts.i = "interactive";
 short_opts.e = "echo";
 
@@ -118,7 +118,7 @@
 					conn:close();
 				end
 			end
-			stdin = require "net.server".wrapclient(stdin, "stdin", 0, {
+			stdin = verse.server.wrapclient(stdin, "stdin", 0, {
 				onincoming = on_incoming, ondisconnect = function () conn:close() end, onreadtimeout = function () return true; end
 				}, "*l");
 		else
--- a/clix/roster.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/roster.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,6 +1,6 @@
 local verse = require "verse"
 short_opts.i = "interactive";
-local split_jid = require "util.jid".split;
+local split_jid = require "prosody.util.jid".split;
 local function printor(str)
 	return function(ok, err)
 		if ok then
@@ -115,7 +115,7 @@
 						groups = { unpack(item.groups) };
 					}
 				end
-				print("return "..require"util.serialization".serialize(stored_roster));
+				print("return "..require"prosody.util.serialization".serialize(stored_roster));
 			end
 		}
 		function commands.help ()
@@ -132,7 +132,7 @@
 				commands[cmd](param);
 			end
 		end
-		stdin = require "net.server".wrapclient(stdin, "stdin", 0, {
+		stdin = verse.server.wrapclient(stdin, "stdin", 0, {
 			onincoming = on_incoming, ondisconnect = function () end
 		}, "*l");
 		conn:add_plugin("roster");
--- a/clix/send.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/send.lua	Fri May 26 22:39:38 2023 +0200
@@ -41,7 +41,7 @@
 					conn:close();
 				end
 			end
-			stdin = require "net.server".wrapclient(stdin, "stdin", 0, {
+			stdin = verse.server.wrapclient(stdin, "stdin", 0, {
 				onincoming = on_incoming, ondisconnect = function () end
 				}, "*l");
 		else
--- a/clix/vcard.lua	Thu Mar 02 18:01:05 2023 +0100
+++ b/clix/vcard.lua	Fri May 26 22:39:38 2023 +0200
@@ -1,5 +1,5 @@
 local t_insert, t_concat = table.insert, table.concat;
-local vcard_to_text = require"util.vcard".to_text;
+local vcard_to_text = require"verse.util.vcard".to_text;
 
 return function (opts, arg)
 	if opts.short_help then