summaryrefslogtreecommitdiff
path: root/notes/config_format.txt
blob: e93b35aca36510743258ae14f0eb1ef62b6e8d8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

Configuration file format
=========================

Common formats:
1. key=value with # comments
2. key=value with [sections] and # comments
3. toml, which is key="value", key=["value"], key=123 etc. (plus [sections] I think?)
4. yaml, which is indented and maybe not a very good idea
5. json


2 and 3 are probably the best options.

for 2 we could also have data types
- all data is trimmed before parsing!
- string: data is parsed as is. should spanning over multiple lines with \ (and then indented) be allowed?
-- how to specify a string with a trailing \
-- maybe we can quote it in that case?
- multiline string: could be indented.
- boolean
- integer
- list: a, b, c  (elements can be of string, boolean or integer type)
-- when a list in a string contains commas, or starts with a double quote, we could wrap it:
--- "a,1", "\"b", "c\\"

or, we just go with a simple variant of 2:
- multi-word strings (when the following lines are indented, they are merged. blank indented lines are considered blank, i.e. ends the value)
- no-space strings (like regular strings, but spaces are skipped when there are multiple lines)
- multiline strings (second and following lines are indented)
-- if a following line is . the it's considered blank
- boolean
- integer
- list: a, b, c  (items must be simple strings (no commas, line wrapping, etc., or booleans, or integers)
-- elements are trimmed
-- nested lists are not supported

should we allow multi-space indentation in trimmed strings?
should we enforce it?
- we could require/allow 4 spaces indentation, at least for everything except multiline strings.
- we could require/allow alignment with the = character

Example
-------

    [section]
    key_str=value
    key_int=123
    key_boolean=true

    key_wrapped_str=test
     continues here
    key_multiline_str=first
     second
     third

    key_int_list = 1, 2, 3
    # when lists are wrapped, the line must end with a comma
    key_int_list_wrapped = 1,
     2,
     3
    key_bool_list = true, false, true
    # lists may start with the item on the second line, and may end with a trailing comma
    key_bool_list_wrapped =
     true,
     false,
    key_str_list = a, b, c
    # strings may not be wrapped in lists, and may not contain commas
    key_str_list_wrapped = a b c d,
     e,
    # elements are trimmed
    key_str_trimmed = a,b    ,   c,  d,
       e,  f   ,