From 8a7b6c9fd0d39b35f267203d0c9906b8ad08e6bb Mon Sep 17 00:00:00 2001 From: luneko Date: Thu, 30 Dec 2021 15:23:51 +0100 Subject: [PATCH] added actual json to default config --- src/kotatsu.cr | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/kotatsu.cr b/src/kotatsu.cr index 14bbe28..a3764be 100644 --- a/src/kotatsu.cr +++ b/src/kotatsu.cr @@ -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)