added actual json to default config

This commit is contained in:
2021-12-30 15:23:51 +01:00
parent 8bd123a030
commit 8a7b6c9fd0

View File

@@ -2,12 +2,38 @@
require "option_parser"
require "http/server"
require "json"
module Kotatsu
VERSION = "0.1.0"
CONFIG_DIR = Path.new(Path.home, ".config", "kotatsu")
CONFIG_FILE = Path.new(CONFIG_DIR, "config.json")
def self.buildConfig()
conf = JSON.build do |json|
json.object do
json.field "config_version", 1
json.field "port", 8080
json.field "title", "Kotatsu"
json.field "services" do
json.array do
json.array do
json.string "Peko! Peko! Peko!"
json.string "https://peko.dance/"
json.string "none"
end
json.array do
json.string "Entertainment Company"
json.string "https://hololive.dance/"
json.string "none"
end
end
end
end
end
return conf
end
def self.makeConfig(file, dir)
puts "Creating new config file in #{file}"
if Dir.exists?(dir) == false
@@ -17,7 +43,7 @@ module Kotatsu
exit(1)
end
end
File.write(file, VERSION)
File.write(file, buildConfig())
if File.exists?(file) == false
STDERR.puts "ERROR! Could not create file: #{file}"
exit(1)