Comparison

prosodyctl @ 1102:c81df501fd38

prosodyctl: Hide ejabberd compatibility commands from command listing
author Matthew Wild <mwild1@gmail.com>
date Sun, 03 May 2009 17:24:35 +0100
parent 1089:a817cbaa0f46
child 1114:c463e30da312
comparison
equal deleted inserted replaced
1101:fb096ca4b296 1102:c81df501fd38
317 -- ejabberdctl compatibility 317 -- ejabberdctl compatibility
318 318
319 function commands.register(arg) 319 function commands.register(arg)
320 local user, host, password = unpack(arg); 320 local user, host, password = unpack(arg);
321 if (not (user and host)) or arg[1] == "--help" then 321 if (not (user and host)) or arg[1] == "--help" then
322 if not user and user ~= "--help" then 322 if user ~= "--help" then
323 show_message [[No username specified]] 323 if not user then
324 elseif not host then 324 show_message [[No username specified]]
325 show_message [[Please specify which host you want to register the user on]]; 325 elseif not host then
326 show_message [[Please specify which host you want to register the user on]];
327 end
326 end 328 end
327 show_usage("register USER HOST [PASSWORD]", "Register a user on the server, with the given password"); 329 show_usage("register USER HOST [PASSWORD]", "Register a user on the server, with the given password");
328 return 1; 330 return 1;
329 end 331 end
330 if not password then 332 if not password then
344 end 346 end
345 347
346 function commands.unregister(arg) 348 function commands.unregister(arg)
347 local user, host = unpack(arg); 349 local user, host = unpack(arg);
348 if (not (user and host)) or arg[1] == "--help" then 350 if (not (user and host)) or arg[1] == "--help" then
349 if not user then 351 if user ~= "--help" then
350 show_message [[No username specified]] 352 if not user then
351 elseif not host then 353 show_message [[No username specified]]
352 show_message [[Please specify which host you want to unregister the user from]]; 354 elseif not host then
353 end 355 show_message [[Please specify which host you want to unregister the user from]];
354 show_usage("register USER HOST [PASSWORD]", "Permanently remove a user account from the server"); 356 end
357 end
358 show_usage("unregister USER HOST [PASSWORD]", "Permanently remove a user account from the server");
355 return 1; 359 return 1;
356 end 360 end
357 361
358 local ok, msg = prosodyctl.deluser { user = user, host = host }; 362 local ok, msg = prosodyctl.deluser { user = user, host = host };
359 363
376 print(""); 380 print("");
377 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); 381 print("Usage: "..arg[0].." COMMAND [OPTIONS]");
378 print(""); 382 print("");
379 print("Where COMMAND may be one of:\n"); 383 print("Where COMMAND may be one of:\n");
380 384
385 local hidden_commands = require "util.set".new{ "register", "unregister" };
381 local commands_order = { "adduser", "passwd", "deluser" }; 386 local commands_order = { "adduser", "passwd", "deluser" };
382 387
383 local done = {}; 388 local done = {};
384 389
385 for _, command_name in ipairs(commands_order) do 390 for _, command_name in ipairs(commands_order) do
390 done[command_name] = true; 395 done[command_name] = true;
391 end 396 end
392 end 397 end
393 398
394 for command_name, command in pairs(commands) do 399 for command_name, command in pairs(commands) do
395 if not done[command_name] then 400 if not done[command_name] and not hidden_commands:contains(command_name) then
396 command{ "--help" }; 401 command{ "--help" };
397 print"" 402 print""
398 done[command_name] = true; 403 done[command_name] = true;
399 end 404 end
400 end 405 end