Skip to content

Commit

Permalink
fix: enums snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
guglielmo-boi committed Apr 3, 2024
1 parent 66341d5 commit 29ecb28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/generator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ def parse_report_tree(key: str, node: dict, parent_config: dict) -> list:

return topics

def role_enum_name(role: str) -> str:
return 'role_' + re.sub(r'(?<!^)(?=[A-Z])', '_', role).lower()

def topic_enum_name(topic: str) -> str:
return (topic[0].lower() + topic[1:])
return re.sub(r'(?<!^)(?=[A-Z])', '_', topic).lower()

def topic_get_name(topic: str) -> str:
return ('GetTopic' + topic)
Expand Down
2 changes: 1 addition & 1 deletion src/templates/topics.h.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace MQTTTopics
enum class Role
{
{%- for role in roles %}
role{{ role.capitalize() }} = {{ loop.index - 1}}
{{ utils.role_enum_name(role) }} = {{ loop.index - 1}}
{%- if not loop.last -%} , {%- endif -%}
{%- endfor %}
};
Expand Down

0 comments on commit 29ecb28

Please sign in to comment.