From 0139b8b7896f6fcc89b3e2481d315e96af82ec4a Mon Sep 17 00:00:00 2001 From: historia Date: Tue, 6 Aug 2024 03:23:06 -0400 Subject: Added config file --- src/then.nim | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/then.nim b/src/then.nim index cfd0b44..4f4199d 100644 --- a/src/then.nim +++ b/src/then.nim @@ -1,5 +1,5 @@ -import std/[times, os, strutils, strbasics, strscans, sets, tables], parseopt -import then/[conditions,typechecker] +import std/[times, os, strutils, strbasics, strscans, sets, strtabs, tables], parseopt +import then/[conditions, config, typechecker] const VERSION = "0.1" const configDir = expandTilde("~/.config/then/") @@ -9,25 +9,6 @@ const defaultCalendarFile = configDir & "calendar.then" const MONTHS = DefaultLocale.MMM.toHashSet + DefaultLocale.MMMM.toHashSet const WEEKDAYS = DefaultLocale.ddd.toHashSet + DefaultLocale.dddd.toHashSet -# Creates a default configuration file if it doesn't exist -proc createDefaultConfigFile() = - if not fileExists(defaultConfigFile): - if not dirExists(configDir): - createDir(configDir) - writeFile(defaultConfigFile, """ - [config] - directory = "~/.config/then/" - """) - -# Creates a default calendar file if it doesn't exist -proc createDefaultCalendarFile() = - if not fileExists(defaultCalendarFile): - if not dirExists(configDir): - createDir(configDir) - writeFile(defaultCalendarFile, """ - # Add your events here - """) - proc printHelp(badCmd: string) = if badCmd != "": echo badCmd & " is not a valid option\n" @@ -130,6 +111,8 @@ proc printCalendar() = printEvents(cal, curDay, "ddd yyyy MMM dd") proc main() = + var config = loadConfig() + echo config var past: int = 1 var future: int = 14 var noArg: bool = true -- cgit v1.2.3