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

utils/cobrautil/templates: new value type search algorithm #324

Merged
merged 1 commit into from Aug 1, 2023

Conversation

mmatczuk
Copy link
Contributor

@mmatczuk mmatczuk commented Aug 1, 2023

This patch replaces regexp with manual searching for matching bracket. The regexp implementation is not aware of the brackets semantics and matches the last closing bracket preventing the use of <> and [] later in usage. The current implementation finds the value type definition until the first upper case letter.

This patch replaces regexp with manual searching for matching bracket.
The regexp implementation is not aware of the brackets semantics and matches the last closing bracket preventing the use of <> and [] later in usage.
The current implementation finds the value type definition until the first upper case letter.
@what-the-diff
Copy link

what-the-diff bot commented Aug 1, 2023

PR Summary

  • Incorporation of 'unicode' Import
    The code was updated to begin utilizing unicode standards to better handle a variety of characters. This occurred in the file help_flags_printer.go.

  • Removal of 'regexp' Import in the Same File
    This modification made the file help_flags_printer.go more efficient by removing unneeded complexity linked to the previously used pattern matching technique ("regexp").

  • Creation of a 'findValueType' Function
    A tool was introduced to help locate the position of value types within a particular string of text. This has made identifying and separating different value types a smoother process.

  • Redefinition of 'flagNameAndUsage' Function
    There were updates to this function that have enabled it to make use of the new 'findValueType' feature, improving its overall performance in extracting flag names and usages.

  • Optimization of 'flagNameAndUsage' Function
    The code governing the extraction of flag names and usages received an upgrade, enabling it to perform more accurately.

  • Augmentation of 'envName' Function
    This update allowed for the function to effectively replace "." and "-" in a flag's name with "_", promoting better clarity and readability of the code.

@Choraden
Copy link
Contributor

Choraden commented Aug 1, 2023

I was just wondering what messed up the pac flag description

@Choraden
Copy link
Contributor

Choraden commented Aug 1, 2023

Basing on the assumption of uppercase letter might be error prone. Maybe we could some document this behaviour in bind package.

@mmatczuk
Copy link
Contributor Author

mmatczuk commented Aug 1, 2023

The alternative is invent a magic char sequence and apply it as a marker to every usage.
For example "\n" could be good choice but you have to keep it in mind or maintain it which is even more error prone.

The uppercase is fine under the assumption that you always begin sentence with an upper case letter.

Waiting for more concrete suggestions.

@Choraden
Copy link
Contributor

Choraden commented Aug 1, 2023

I had a very similar idea with a magic char '. Moreover, we could force users to explicitly define value type. This is return error when value is not matched.

@mmatczuk
Copy link
Contributor Author

mmatczuk commented Aug 1, 2023

I prefer to limit scope of the changes to the docs.

@mmatczuk mmatczuk merged commit 4764ca0 into main Aug 1, 2023
3 checks passed
@mmatczuk mmatczuk deleted the mmt/cmd_layout_fix branch August 1, 2023 14:58
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.

None yet

2 participants