Start work on config file
This commit is contained in:
parent
2f0caa12f9
commit
2e5ede21cb
3 changed files with 84 additions and 13 deletions
29
src/handlers/configHandler.nim
Normal file
29
src/handlers/configHandler.nim
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
const
|
||||||
|
dashinitConfig = staticRead("../resources/config.toml")
|
||||||
|
|
||||||
|
proc createConfigFile*() =
|
||||||
|
var configPath: string
|
||||||
|
|
||||||
|
# Determine the build type
|
||||||
|
when defined(release):
|
||||||
|
# Determine the operating system
|
||||||
|
when defined(windows):
|
||||||
|
configPath = os.getHomeDir() / "dashinit" / "config.toml"
|
||||||
|
else:
|
||||||
|
configPath = os.getHomeDir() / ".config" / "dashinit" / "config.toml"
|
||||||
|
else:
|
||||||
|
configPath = getAppFilename().parentDir() / "config.toml"
|
||||||
|
|
||||||
|
# Create the directory if it doesn't exist
|
||||||
|
let dir = configPath.parentDir()
|
||||||
|
if not dir.dirExists():
|
||||||
|
dir.createDir()
|
||||||
|
|
||||||
|
# Write the template config to the determined path
|
||||||
|
if not configPath.fileExists():
|
||||||
|
writeFile(configPath, dashinitConfig)
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
createConfigFile()
|
|
@ -2,8 +2,10 @@
|
||||||
import os, strutils
|
import os, strutils
|
||||||
import subcommands/help
|
import subcommands/help
|
||||||
import subcommands/init
|
import subcommands/init
|
||||||
|
import handlers/configHandler
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
|
createConfigFile()
|
||||||
let args = commandLineParams()
|
let args = commandLineParams()
|
||||||
if args.len == 0:
|
if args.len == 0:
|
||||||
init()
|
init()
|
||||||
|
|
40
src/resources/config.toml
Normal file
40
src/resources/config.toml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# dashinit Configuration File
|
||||||
|
|
||||||
|
[general]
|
||||||
|
# Where to download templates from
|
||||||
|
template_repo = "https://gitpot.dev/dashinit/templates"
|
||||||
|
|
||||||
|
# The default template to be used when initialising
|
||||||
|
default_template = "default"
|
||||||
|
|
||||||
|
[templates]
|
||||||
|
# Allow user scripts to be executed
|
||||||
|
allow_scripts = false
|
||||||
|
|
||||||
|
# If allow_scripts is set to false, these scripts will still be executable
|
||||||
|
script_whitelist = [
|
||||||
|
"default/default.sh"
|
||||||
|
# "template/script.sh",
|
||||||
|
# "~/.local/share/dashinit/scripts/script.sh" # full paths are also possible
|
||||||
|
]
|
||||||
|
|
||||||
|
[updates]
|
||||||
|
# Check for updates periodically. Disabled by default
|
||||||
|
check = false
|
||||||
|
|
||||||
|
# Frequency to check for updates. (daily, weekly, monthly)
|
||||||
|
# If an unrecognized value is provided, it defaults to 'weekly'
|
||||||
|
frequency = "weekly"
|
||||||
|
|
||||||
|
[logs]
|
||||||
|
# Whether logs are enabled or not
|
||||||
|
enabled = false
|
||||||
|
|
||||||
|
# Specify log level (info, warning, error, debug)
|
||||||
|
level = "info"
|
||||||
|
|
||||||
|
# Where the logs should be stored
|
||||||
|
path = "~/.local/share/dashinit/logs"
|
||||||
|
|
||||||
|
# Maximum log size in MB before a new log gets created
|
||||||
|
max_size = 10
|
Loading…
Reference in a new issue