added option to add service

This commit is contained in:
2021-12-30 17:45:24 +01:00
parent c730a2213c
commit 4fc6ac892f

View File

@@ -114,6 +114,33 @@ module Kotatsu
end
end
parser.on "add", "Add a service" do
if File.exists?(CONFIG_FILE) == true
version, port, title, services = readConfig()
print "Name: "
s_name = gets.to_s
print "Link: "
s_link = gets.to_s
print "Icon: "
s_icon = gets.to_s
s_service = [s_name, s_link, s_icon]
services_new = [] of Array(String)
i = 0
while services.size > i
services_new << services[i]
i+=1
end
services_new << s_service
writeConfig(version, port, title, services_new)
exit
else
STDERR.puts "ERROR! Config file not found: #{CONFIG_FILE}"
exit(1)
end
end
parser.on "list", "Lists all services" do
if File.exists?(CONFIG_FILE) == true
_, _, _, services = readConfig()