Skip to content

Commit

Permalink
fix function names
Browse files Browse the repository at this point in the history
  • Loading branch information
reschandreas committed Dec 17, 2023
1 parent f636c4f commit 51ade29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions cli/generators/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pylint: disable=duplicate-code
import os
import re
import subprocess
import tempfile
import typing
Expand Down Expand Up @@ -64,7 +65,7 @@ def add_postfix(self) -> None:
# to enable sourceing the script, we need to skip execution if we do so
# for that, we check if the first parameter is sourcing, which is not ever given to the script elsewhere
self.add_line(indentation=2, line='local _current_lifecycle="${1}"')
self.add_line(indentation=4, line='if [[ "${{_current_lifecycle}}" == "aeolus_sourcing" ]]; then')
self.add_line(indentation=4, line='if [[ "${_current_lifecycle}" == "aeolus_sourcing" ]]; then')
self.add_line(indentation=4, line="# just source to use the methods in the subshell, no execution")
self.add_line(indentation=4, line="return 0")
self.add_line(indentation=2, line="fi")
Expand Down Expand Up @@ -169,9 +170,10 @@ def handle_step(self, name: str, step: ScriptAction, call: bool) -> None:
self.result.append(f"# step {name}")
self.result.append(f"# generated from step {original_name}")
self.result.append(f"# original type was {original_type}")
valid_funtion_name: str = re.sub('[^a-zA-Z]+', '', name)
if call:
self.functions.append(name)
self.result.append(f"{name} () " + "{")
self.functions.append(valid_funtion_name)
self.result.append(f"{valid_funtion_name} () " + "{")
self.add_lifecycle_guards(name=name, exclusions=step.excludeDuring, indentations=2)

self.add_line(indentation=2, line="echo '⚙️ executing " f"{name}'")
Expand Down
6 changes: 4 additions & 2 deletions cli/test/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ def test_generate_valid_cli_script(self) -> None:
result: str = cli.generate()
self.assertTrue(result.count("#!/usr/bin/env bash") == 1)
self.assertTrue("set -e" in result)
# two comments, one definition, one echo for execution, one echo in the actual action, and one call
self.assertTrue(result.count("internal-action") == 5)
# two comments, one echo for execution, one echo in the actual action
self.assertTrue(result.count("internal-action") == 3)
# one call to the function and the function itself
self.assertTrue(result.count("internalaction") == 2)
self.assertTrue(result.count("{") == result.count("}"))
self.assertTrue(cli.check(content=result))

Expand Down

0 comments on commit 51ade29

Please sign in to comment.