Comparison

prosodyctl @ 10134:e5132c4cfb81

prosodyctl: Complemented my functions with return calls, when possible
author João Duarte <jvsDuarte08@gmail.com>
date Wed, 26 Jun 2019 16:46:51 +0100
parent 10133:73bae75c6d77
child 10135:3ae2809030dd
comparison
equal deleted inserted replaced
10133:73bae75c6d77 10134:e5132c4cfb81
8 -- 8 --
9 9
10 -- prosodyctl - command-line controller for Prosody XMPP server 10 -- prosodyctl - command-line controller for Prosody XMPP server
11 11
12 -- Will be modified by configure script if run -- 12 -- Will be modified by configure script if run --
13
14 CFG_SOURCEDIR=CFG_SOURCEDIR or os.getenv("PROSODY_SRCDIR"); 13 CFG_SOURCEDIR=CFG_SOURCEDIR or os.getenv("PROSODY_SRCDIR");
15 CFG_CONFIGDIR=CFG_CONFIGDIR or os.getenv("PROSODY_CFGDIR"); 14 CFG_CONFIGDIR=CFG_CONFIGDIR or os.getenv("PROSODY_CFGDIR");
16 CFG_PLUGINDIR=CFG_PLUGINDIR or os.getenv("PROSODY_PLUGINDIR"); 15 CFG_PLUGINDIR=CFG_PLUGINDIR or os.getenv("PROSODY_PLUGINDIR");
17 CFG_DATADIR=CFG_DATADIR or os.getenv("PROSODY_DATADIR"); 16 CFG_DATADIR=CFG_DATADIR or os.getenv("PROSODY_DATADIR");
18 17
91 -- I'm considering the flag is the first, but there can be many flags 90 -- I'm considering the flag is the first, but there can be many flags
92 if arg[1] and arg[1]:sub(1, #flag) == flag then 91 if arg[1] and arg[1]:sub(1, #flag) == flag then
93 local dir = arg[1]:match("=(.+)$") 92 local dir = arg[1]:match("=(.+)$")
94 -- These extra double brackets allow us to correctly process names with spaces 93 -- These extra double brackets allow us to correctly process names with spaces
95 os.execute("luarocks list --tree=".."'"..dir.."'") 94 os.execute("luarocks list --tree=".."'"..dir.."'")
95 return 0;
96 else 96 else
97 os.execute("luarocks list --tree="..prosody.paths.data.."/rocks") 97 os.execute("luarocks list --tree="..prosody.paths.data.."/rocks")
98 return 0;
98 end 99 end
99 end 100 end
100 101
101 function commands.admin_add(arg) 102 function commands.admin_add(arg)
102 prosodyctl.admin_operation("add ", arg) 103 prosodyctl.admin_operation("add ", arg)
104 return 0;
103 end 105 end
104 106
105 function commands.admin_remove(arg) 107 function commands.admin_remove(arg)
106 prosodyctl.admin_operation("remove ", arg) 108 prosodyctl.admin_operation("remove ", arg)
109 return 0;
107 end 110 end
108 111
109 function commands.enabled_plugins() 112 function commands.enabled_plugins()
110 for module in modulemanager.get_modules_for_host() do 113 for module in modulemanager.get_modules_for_host() do
111 show_warning("%s", module) 114 show_warning("%s", module)
124 t[i] = filename 127 t[i] = filename
125 show_warning("%s", t[i]) 128 show_warning("%s", t[i])
126 end 129 end
127 end 130 end
128 pfile:close() 131 pfile:close()
132 return 0
129 end 133 end
130 134
131 function commands.adduser(arg) 135 function commands.adduser(arg)
132 if not arg[1] or arg[1] == "--help" then 136 if not arg[1] or arg[1] == "--help" then
133 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); 137 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]);