dotfilebackup_design_docs.md 8.4 KB

additional features

- cli autocompleate

parser for .backup config format

such config file

# comment

key: val  # inline comment

multiline_inline: --- this is a long text
                      that spans few lines to
                      simulate multi line value
                      ---

multiline_next_line: ---
    this is a long text       # indentation will be stripped
    that spans few lines to   # this line spaces from "to" to "#" will be stripped
                              # empty empty lines will be stripped and preserved
                              # line with only comments are considered empty
    simulate multi line value
    ---

list::                             # notice double colons
    - val-1 -                      # notice hyphen/minus in value
    - -- val-2                     # only '- ' or "- --- " present at the
    - val-3---                     # line BEGINNING are significant and
    - --- this is a long text      # will be stripped alongside indentation
          that spans few lines to
          simulate multi line value
          ---
    - ---
      this is a long text
      that spans few lines to
      simulate multi line value
      ---

# dictionary
dictionary:
    key_1: val_1
    key_2: --- this is a long text
               that spans few lines to
               simulate multi line value ---

    key_3: --- this is a long text
               that spans few lines to
               simulate multi line value---

    # empty lines are ignored
    key_4: ---
           this is a long text  
           that spans few lines to
           simulate multi line value
           ---
    key_5: ---
           this is a long text  
           that spans few lines to
           simulate multi line value---
    key_6: ---
           this is a long text  
           that spans few lines to
           simulate multi line value ---

curly_braces_use: {r"""}
    curly braces support all advanced functions, and can be used for:
    - raw string      use {r"""} and {_"""_}  # treat '_' as '' here
                      or  {r'''} and {'''}
    - interpolations  use {interpolation_name}

    only letters, numbers, "-" and "_" characters are allowed in names

    any curly braces will be replaced by what they return
    the only exeption is raw string witch returns
    what is between it's start and end marker

    AlL naMES ARe caSE SenSitiVE
    {"""}

raw_string: {r'''}
            read from start marker {r"""}/{r'''} to finish marker,
            finish markers cannot be escaped, indentation is stripped
            no interpolations, variables or any of the sort

            ps. was tempted to use {alcatraz} name instead XD
            {'''}

menu_json: {r"""}
    {"menu": {
       "id": "contact",
       "text": "contact",
       "popup": {
         "items": [
           {"value": "email", "onclick": "OpenChat()"},
           {"value": "chat", "onclick": "OpenEmail()"},
         ]
       }
    }
    {"""}

interpolations: {r"""}
    use curly brackets with name inside kinda like python f string formatting

    available:
        colon                  use {colon}               or {c}
        hash                   use {hash}                or {h}
        hyphen/minus           use {hyphen}/{minus}      or {m}
        triple hyphen/minus    use {3hyphen}/{3minus}    or {mmm}  # better m&m's
        left  bracket          use {left_curly}          or {l}
        right bracket          use {right_curly}         or {r}
    {"""}

scary_things::
    - {mmm} starting cli flags
    - meats of {h}00FF00 color
    - people with {left_curly} and {right_curly} hair  # XD   

# combo example
interesting::
    - facts::
        - sir Isaac Newton was really into occult stuff
        - first apple logo had sir Isaac Newton in it
    - questions::
        - how:
            - many rotten apples it takes to get high
            - many newtons it takes to bend an apple

# preserve indentation level for each local scope/level/context
# parser:
#    |motivation: ---
#    |           |this parser was written because
#    |           |configparser did not offer option
#    |           |to not parse particular section or
#    |           |to pass some kind of parse function
#    |           |---
#    |why_not:
#    |   |yaml::
#    |   |   |- quotation required for all string values
#    |   |   |- single quotes and double quotes work differently
#    |   |   |
#    |   |   |- --- writing regexes in quotes requires escaping
#    |   |   |     |characters witch makes regexes less readable
#    |   |   |     |---
#    |   |json: why ask when you already know?
#    |   |toml: configparser is simpler

will get you

{
    'key': 'val',
    'multiline_inline':
        'this is a long text\n'
        'that spans few lines to\n'
        'simulate multi line value\n',
    'multiline_next_line':
        'this is a long text\n'
        'that spans few lines to\n'
        '\n'
        '\n'
        'simulate multi line value\n',
    'list': [
        'val-1 -',
        '-- val-2',
        'val-3---',
        'this is a long text\n'
            'that spans few lines to\n'
            'simulate multi line value\n',
        'this is a long text\n'
            'that spans few lines to\n'
            'simulate multi line value\n',
    ]
    'dictionary': {
        'key_1': 'val_1',
        'key_2':
            'this is a long text\n'
            'that spans few lines to\n'
            'simulate multi line value',                              # no ' \n'
        'key_3':
            'this is a long text\n'
            'that spans few lines to\n'
            'simulate multi line value',                               # no '\n'
        'key_4':
            'this is a long text\n'
            'that spans few lines to\n'
            'simulate multi line value\n',
        'key_5':
            'this is a long text\n'
            'that spans few lines to\n'
            'simulate multi line value\n',                             # no '\n'
        'key_6':
            'this is a long text\n'
            'that spans few lines to\n'
            'simulate multi line value\n',                            # no ' \n'
    }
    'curly_braces_use':
        'curly braces support all advanced functions, and can be used for:\n'
        '- raw string      use {r"""} and {_"""_}  # treat '_' as '' here\n'
        "                  or  {r'} and {'''}\n"
        '- interpolations  use {interpolation_name}\n'
        '\n'
        'only letters, numbers, "-" and "_" characters are allowed in names\n'
        '\n'
        'any curly braces will be replaced by what they return\n'
        'the only exeption is raw string witch returns\n'
        "what is between it's start and end marker\n"
        '\n'
        'AlL naMES ARe caSE SenSitiVE\n',
    'raw_string':
        'read from start marker {r"""}/{r\'\'\'} to finish marker,\n'
        'finish markers cannot be escaped, indentation is stripped\n'
        'no interpolations, variables or any of the sort\n'
        '\n'
        'ps. was tempted to use {alcatraz} name instead XD\n',
    'menu_json':
        '{"menu": {\n'
        '  "id": "contact",\n'
        '  "text": "contact",\n'
        '   "popup": {\n'
        '     "items": [\n'
        '       {"value": "email", "onclick": "OpenChat()"},\n'
        '       {"value": "chat", "onclick": "OpenEmail()"},\n'
        '     ]\n'
        '  }\n'
        '}\n',
    'interpolations':
        'use curly brackets with name inside kinda like python f string formatting\n'
        '\n'
        'available:\n'
        '    colon                  use {colon}               or {c}\n'
        '    hash                   use {hash}                or {h}\n'
        '    hyphen/minus           use {hyphen}/{minus}      or {m}\n'
        "    triple hyphen/minus    use {3hyphen}/{3minus}    or {mmm}  # better m&m's\n"
        '    left  bracket          use {left_curly}          or {l}\n'
        '    right bracket          use {right_curly}         or {r}\n',
    'scary_things': [
        '--- starting cli flags',
        'meats of #00FF00 color',
        'people with { and } hair',
    ]
    'interesting': [
        'facts': [
            'sir Isaac Newton was really into occult stuff',
            'first apple logo had sir Isaac Newton in it',
        ]
        'questions': {
            'how': [
                'many rotten apples it takes to get high',
                'many newtons it takes to bend an apple',
            ]
        }
    ]
}

#