Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow unescaped quoted strings with --config CLI #2835

Merged
merged 4 commits into from
Jul 23, 2020

Conversation

wezrule
Copy link
Contributor

@wezrule wezrule commented Jul 1, 2020

This task was originally because of confusion around this error found by @guilhermelawless:
./nano_node --network live --daemon --config node.online_weight_minimum="40000000000000000000000000000000000000"

Error deserializing config: Malformed number (out of range: stoll) at line 1

The docs state that strings should be escaped. Would be nice if non-escaped quotes could be done which is what this PR has added.

To solve this we are now separating the key and value, then appending them together with the value being surrounded in escaped quotations if they are not added by the command. Toml seems to be able to handle this fine based on various tests. Reviewers should test a variety of options with different types (bool/int/string for instance).

@wezrule wezrule added bug cli Changes related to the Command Line Interface labels Jul 1, 2020
@wezrule wezrule added this to the V22.0 milestone Jul 1, 2020
@wezrule wezrule self-assigned this Jul 1, 2020
argakiig
argakiig previously approved these changes Jul 1, 2020
@wezrule wezrule removed the bug label Jul 2, 2020
@wezrule wezrule marked this pull request as draft July 2, 2020 09:17
@wezrule wezrule changed the title Parsing issue with --config CLI Allow unescaped quoted strings with --config CLI Jul 2, 2020
@wezrule wezrule marked this pull request as ready for review July 2, 2020 15:49
Copy link
Contributor

@guilhermelawless guilhermelawless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested:

  • node.active_elections_size
  • node.httpcallback.address
  • node.max_work_generate_multiplier
  • node.work_peers

No regressions and all of them now work with unescaped quotes or even no quotes.

However noticed on arrays like node.work_peers it's not possible to give --config node.work_peers=["127.0.0.1:7000"] , the quotes must be escaped instead: --config node.work_peers=[\"127.0.0.1:7000\"].

Using the approach of this PR, can this case be handled? If not, LGTM but the documentation should note this particular case.

@wezrule
Copy link
Contributor Author

wezrule commented Jul 13, 2020

@guilhermelawless I have added support for arrays, thanks for finding that during testing.

@wezrule wezrule added the documentation This item indicates the need for or supplies updated or expanded documentation label Jul 14, 2020
Copy link
Contributor

@guilhermelawless guilhermelawless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working great!
Could change some ss << "(char)" to single quotes but not too important.

A note for documentation is that arrays must not have spaces in between entries.

@wezrule wezrule merged commit facc103 into nanocurrency:develop Jul 23, 2020
@wezrule wezrule deleted the cli_config_parsing_error branch July 23, 2020 10:19
@zhyatt zhyatt added breaking Change to node APIs (separate label) which impacts existing implementation, integrations impacted. and removed breaking Change to node APIs (separate label) which impacts existing implementation, integrations impacted. labels Oct 23, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
cli Changes related to the Command Line Interface documentation This item indicates the need for or supplies updated or expanded documentation enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants