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

refactor: validate defcfg values in parser #624

Merged
merged 17 commits into from
Nov 22, 2023
Merged

Conversation

rszyma
Copy link
Contributor

@rszyma rszyma commented Nov 13, 2023

Describe your changes. Use imperative present tense.

  1. Move validation of cfg values to parse_defcfg instead of validating them all over the codebase. Reason: before kanata didn't show location when parsing of a cfg value failed, now it does.
  2. Replace HashMap<String, String> with CfgOptions, which holds only validated cfg values. Reason: Allows to easily parse lists as values, since now the actual value parsing is no longer delayed after parser function exited. This was done with Do not use : to separate linux devices #121 in mind.
  3. Move cfg options defaults to a CfgOptions::default. Reason: it's good to have similar code in one place.

Checklist

  • Add documentation to docs/config.adoc
    • N/A
  • Add example and basic docs to cfg_samples/kanata.kbd
    • N/A
  • Update error messages
    • Yes
  • Added tests, or did manual testing
    • manual testing

This will come useful in later commits where defcfg will be validated on
the spot, and the only barrier to doing that is `linux-unicode-u-code`
which can accept user-defined localkeys.
@rszyma rszyma changed the title refactor: validate defcfg refactor: validate defcfg values in parser Nov 13, 2023
@rszyma rszyma marked this pull request as draft November 13, 2023 12:47
…ty ParsedState

and also it won't parse for variables (because they are not allowed there anyway)
@rszyma
Copy link
Contributor Author

rszyma commented Nov 13, 2023

pushed some changes to match exact parser behavior with the one on main, I'll do extensive manual testing and eventually some more refactoring of parse_defcfg after getting some feedback

@rszyma rszyma marked this pull request as ready for review November 13, 2023 16:10
src/oskbd/linux.rs Outdated Show resolved Hide resolved
src/kanata/windows/mod.rs Outdated Show resolved Hide resolved
parser/src/cfg/mod.rs Show resolved Hide resolved
parser/src/cfg/mod.rs Show resolved Hide resolved
@rszyma
Copy link
Contributor Author

rszyma commented Nov 20, 2023

Is there anything else I should change?

@jtroo
Copy link
Owner

jtroo commented Nov 20, 2023

Generally seems fine, haven't seen any high level issues. Can merge whenever testing is done.

before, lists of ints without spaces after commas
didn't get parsed correctly
@rszyma
Copy link
Contributor Author

rszyma commented Nov 21, 2023

I'm done

@jtroo jtroo merged commit 1f7af8f into jtroo:main Nov 22, 2023
3 checks passed
@rszyma rszyma deleted the refactor-defcfg branch November 22, 2023 14:02
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.

2 participants