Comparison

prosodyctl @ 10162:7a4c15f75deb

prosodyctl: Removed/rewrote comments at the install, remove and list commands
author João Duarte <jvsDuarte08@gmail.com>
date Wed, 24 Jul 2019 05:07:57 -0700
parent 10161:ea10561e5566
child 10164:d145eb696475
comparison
equal deleted inserted replaced
10161:ea10561e5566 10162:7a4c15f75deb
88 function commands.install(arg) 88 function commands.install(arg)
89 if arg[1] == "--help" then 89 if arg[1] == "--help" then
90 show_usage([[make]], [[Installs a prosody/luarocks plugin]]); 90 show_usage([[make]], [[Installs a prosody/luarocks plugin]]);
91 return 1; 91 return 1;
92 end 92 end
93 -- Need to think about the case with many flags 93 -- I'm considering this optional flag comes first
94 local flag = "--tree=" 94 local flag = "--tree="
95 -- I'm considering the flag is the first, but there can be many flags
96 if arg[1] and arg[1]:sub(1, #flag) == flag then 95 if arg[1] and arg[1]:sub(1, #flag) == flag then
97 local dir = arg[1]:match("=(.+)$") 96 local dir = arg[1]:match("=(.+)$")
98 print("Installing module "..arg[2].." at "..dir) 97 print("Installing module "..arg[2].." at "..dir)
99 -- These extra double brackets allow us to correctly process names with spaces
100 os.execute("luarocks --tree='"..dir.."' --server='http://localhost/' install "..arg[2]) 98 os.execute("luarocks --tree='"..dir.."' --server='http://localhost/' install "..arg[2])
101 show_module_configuration_help(arg[2]); 99 show_module_configuration_help(arg[2]);
102 return 0; 100 return 0;
103 else 101 else
104 print("Installing module "..arg[1].." at "..prosody.paths.plugins) 102 print("Installing module "..arg[1].." at "..prosody.paths.plugins)
108 show_module_configuration_help(arg[1]); 106 show_module_configuration_help(arg[1]);
109 return 0; 107 return 0;
110 end 108 end
111 end 109 end
112 110
113 -- Command to remove a rockspec
114 -- Receives as an argument the name of the plugin to be removed from the plugins folder
115 function commands.remove(arg) 111 function commands.remove(arg)
116 if arg[1] == "--help" then 112 if arg[1] == "--help" then
117 show_usage([[make]], [[Removes a module installed in the wroking directory's plugins folder]]); 113 show_usage([[make]], [[Removes a module installed in the wroking directory's plugins folder]]);
118 return 1; 114 return 1;
119 end 115 end
120 local flag = "--tree=" 116 local flag = "--tree="
121 -- I'm considering the flag is the first, but there can be many flags 117 -- I'm considering this optional flag comes first
122 if arg[1] and arg[1]:sub(1, #flag) == flag then 118 if arg[1] and arg[1]:sub(1, #flag) == flag then
123 local dir = arg[1]:match("=(.+)$") 119 local dir = arg[1]:match("=(.+)$")
124 print("Removing module "..arg[2].." at "..dir) 120 print("Removing module "..arg[2].." at "..dir)
125 -- These extra double brackets allow us to correctly process names with spaces
126 os.execute("luarocks remove --tree='"..dir.."' "..arg[2]) 121 os.execute("luarocks remove --tree='"..dir.."' "..arg[2])
127 return 0; 122 return 0;
128 else 123 else
129 print("Removing "..arg[1].." from "..prosody.paths.plugins) 124 print("Removing "..arg[1].." from "..prosody.paths.plugins)
130 os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1]) 125 os.execute("luarocks --tree='"..prosody.paths.plugins.."' remove "..arg[1])
136 function commands.list(arg) 131 function commands.list(arg)
137 if arg[1] == "--help" then 132 if arg[1] == "--help" then
138 show_usage([[list]], [[Shows installed rocks]]); 133 show_usage([[list]], [[Shows installed rocks]]);
139 return 1; 134 return 1;
140 end 135 end
141 -- Need to think about the case with many flags
142 local flag = "--tree=" 136 local flag = "--tree="
143 -- I'm considering the flag is the first, but there can be many flags 137 -- I'm considering this optional flag comes first
144 if arg[1] and arg[1]:sub(1, #flag) == flag then 138 if arg[1] and arg[1]:sub(1, #flag) == flag then
145 local dir = arg[1]:match("=(.+)$") 139 local dir = arg[1]:match("=(.+)$")
146 -- These extra double brackets allow us to correctly process names with spaces
147 os.execute("luarocks list --tree='"..dir.."'") 140 os.execute("luarocks list --tree='"..dir.."'")
148 return 0; 141 return 0;
149 else 142 else
150 os.execute("luarocks list --tree="..prosody.paths.plugins) 143 os.execute("luarocks list --tree="..prosody.paths.plugins)
151 return 0; 144 return 0;