VladimirMarkelov / ttdl

TTDL - Terminal Todo List Manager
MIT License
210 stars 17 forks source link

Config parse error when specifying global filename #45

Closed Klaboe closed 3 years ago

Klaboe commented 3 years ago

When i tried to specify a global filename for where to store the todo.txt like this:

filename = "C:\Users\<my-username>\Apps\ttdl\todo.txt"

i got this error

Failed to parse config file: Error { inner: ErrorInner { kind: InvalidHexEscape('s'), line: Some(67), col: 16, message: "", key: [] } }

And it used default values.

When i changed from double quotes to single quotes:

filename = 'C:\Users\<my-username>\Apps\ttdl\todo.txt'

it seems to work as expected.

Using Win10 Powershell 7.1.1 ttdl v1.0.0

VladimirMarkelov commented 3 years ago

It is TOML format rules (https://toml.io/en/ - check the section "Powerful strings"):

It looks like \U in the path is parsed as hexadecimal escape code start, but the next s is not a hexadecimal digit, so it raises an error about incorrect hexadecimal number.

So, there are three solutions:

  1. Use single quotes: filename = 'c:\Users\user\todo.txt'
  2. Double backslashes: filename = "c:\\Users\\user\\todo.txt"
  3. Replace backslashes with slashes - Windows can work with both: filename = "c:/Users/user/todo.txt"
Klaboe commented 3 years ago

I'll go with the single-quotes.

But i would maybe mention this in the documentation somewhere. Both what toml is (it was new to me, and for some reason it didn't connect the file-ending to a specific language in this instance 🤦‍♂️) and also that this is a ...caveat with specifying filepaths/names on windows 👍

VladimirMarkelov commented 3 years ago

But i would maybe mention this in the documentation somewhere

I agree, it makes sense. I think the best place is the comment inside the configuration file that explains what filename options is. Or/and in the very beginning of the example configuration file.

I reopen the issue to not forget updating the docs.

Klaboe commented 3 years ago

I think the best place is the comment inside the configuration file

Agreed; this makes sense.

(...) that explains what filename options is. Or/and in the very beginning of the example configuration file.

Why not both? I would, at the start, mention the toml part (and perhaps the url you linked me), and then explain the caveats above the filename-part 👍