Add schema to config

This commit is contained in:
Marko Korhonen 2023-11-23 18:57:14 +02:00
parent 87737b0118
commit 29ded9426b
Signed by: FunctionalHacker
GPG key ID: A7F78BCB859CD890
3 changed files with 61 additions and 4 deletions

55
config/config-schema.json Normal file
View file

@ -0,0 +1,55 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"language": {
"type": "string",
"enum": ["en", "fi"]
}
},
"type": "object",
"properties": {
"language": {
"$ref": "#/definitions/language",
"description": "The language of the application. Currently supported languages are 'en', 'fi'"
},
"timestampFormat": {
"type": "string",
"description": "Time format used to display timestamps (started, stopped, etc.). Refer to the dayjs documentation on how to set this https://day.js.org/docs/en/display/format"
},
"defaults": {
"type": "object",
"properties": {
"lunchBreakDuration": {
"type": "string",
"description": "Set as \"00:00\" if you don't have an unpaid lunch break or if you normally log your lunch break hours"
},
"workDayDuration": { "type": "string", "description": "Your work day duration" },
"startTime": { "type": "string", "description": "The time you start working" },
"stopTime": {
"type": ["string", "null"],
"description": "The time you stop working. Can either be 'now' or a time"
}
},
"required": ["lunchBreakDuration", "workDayDuration", "startTime"],
"additionalProperties": false,
"description": "Default values for inputs"
},
"askInput": {
"type": "object",
"properties": {
"workDayDuration": {
"type": "boolean",
"description": "Disable prompt for work day duration if set to false"
},
"startTime": { "type": "boolean", "description": "Disable prompt for start time if set to false" },
"stopTime": { "type": "boolean", "description": "Disable prompt for stop time if set to false" },
"logged": { "type": "boolean", "description": "Disable prompt for logged time if set to false" },
"hadLunch": { "type": "boolean", "description": "Assumed that you didn't have lunch if this is false" }
},
"additionalProperties": false,
"description": "Settings to disable prompts"
}
},
"additionalProperties": false,
"description": "Work Time Calculator configuration file. Configuration file location: $XDG_CONFIG_HOME/wtc/config.toml, usually ~/.config/wtc/config.toml"
}

46
config/config.toml Normal file
View file

@ -0,0 +1,46 @@
#:schema https://git.korhonen.cc/FunctionalHacker/work-time-calculator/raw/branch/main/config/config-schema.json
# Work Time Calculator configuration file
# This is the default configuration.
# You can only partially override the config,
# any missing values will use the defaults described here.
# On Unix/Linux you can place your configuration file in $XDG_CONFIG_HOME/wtc/config.toml,
# usually ~/.config/wtc/config.toml
# For windows, I don't know.
# The language of the application.
# Currently supported languages are "en", "fi"
language = "en"
# Time format used to display timestamps (started, stopped etc.)
# Refer to the dayjs documentation on how to set this https://day.js.org/docs/en/display/format
# For example, the finnish format would be "MM.DD.YYYY [kello] HH.mm"
timestampFormat = "YYYY-MM-DD HH:mm"
# This section is for default values for inputs
[defaults]
# Set as "00:00" if you don't have an unpaid lunch break
# or if you normally log your lunch break hours
lunchBreakDuration = "00:30"
# Your work day duration
workDayDuration = "07:30"
# The time you start working
startTime = "08:00"
# The time you stop working. Can either be "now" or a time
stopTime = "now"
# This section can be used to disable prompts for each
# of the questions. The default value will be used automatically
# if the setting is set to false
[askInput]
workDayDuration = true
startTime = true
stopTime = true
logged = true
# It is assumed that you didn't have lunch if this is false
hadLunch = true