Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate indented toml config files for improved legibility #4558

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

RickiNano
Copy link
Contributor

The current config layout is quite hard to navigate.
This PR adds indentation to clearly show what is a child object of a node. Indentations are allowed for the TOML format according to the official documentation.
--generate_config cli command has been tested with both node, rpc and log configs. It also supports the --use_defaults command with correct output.
Here is a small sample of the new config file for illustration:

[node.httpcallback]

        # Callback address.
        # type:string,ip
        # address = ""

        # Callback port number.
        # type:uint16
        # port = 0

        # Callback target path.
        # type:string,uri
        # target = ""

[node.ipc.flatbuffers]

        # Allow client to send unknown fields in json messages. These will be ignored.
        # type:bool
        # skip_unexpected_fields_in_json = true

        # Verify that the buffer is valid before parsing. This is recommended when receiving data from untrusted sources.
        # type:bool
        # verify_buffers = true

[node.ipc.local]

        # If enabled, certain unsafe RPCs can be used. Not recommended for production systems.
        # type:bool
        # allow_unsafe = false

        # Enable or disable IPC via local domain socket.
        # type:bool
        # enable = false

        # Timeout for requests.
        # type:seconds
        # io_timeout = 15

        # Path to the local domain socket.
        # type:string
        # path = "/tmp/nano"

[node.ipc.tcp]

        # Enable or disable IPC via TCP server.
        # type:bool
        # enable = false

        # Timeout for requests.
        # type:seconds
        # io_timeout = 15

        # Server listening port.
        # type:uint16
        # port = 7077

@pwojcikdev
Copy link
Contributor

Do we really want to do it? Some time ago I researched a similar approach and was discouraged after reading through toml-lang/toml#608 especially since most tools should offer pretty good toml syntax highlighting.

@RickiNano
Copy link
Contributor Author

The TOML language is not that widespread. Even notepad++ that supports 50+ languages doesn't come with a toml parser.
I prefer it to be indented. It makes it super easy to read no matter what text editor you are using.

@pwojcikdev
Copy link
Contributor

Okay, without a syntax highligher indentation definitely helps.

nano/lib/tomlconfig.cpp Show resolved Hide resolved
@clemahieu clemahieu merged commit e9eaaef into nanocurrency:develop Apr 16, 2024
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants