added option to list all services

This commit is contained in:
2021-12-30 16:04:37 +01:00
parent 8a7b6c9fd0
commit 0e38090ae9

View File

@@ -73,6 +73,22 @@ module Kotatsu
end
end
parser.on "list", "Lists all services" do
if File.exists?(CONFIG_FILE) == true
conf = JSON.parse(File.read(CONFIG_FILE))
services = conf["services"].as_a
i = 0
while services.size > i
puts "##{i}: #{services[i][0]} ; #{services[i][1]} ; #{services[i][2]}"
i+=1
end
exit
else
STDERR.puts "ERROR! Config file not found: #{CONFIG_FILE}"
exit(1)
end
end
parser.invalid_option do |flag|
STDERR.puts "ERROR! Not a valid option: #{flag}"
STDERR.puts "Use -h or --help for all available options"