diff --git a/src/vapython/examples/__main__.py b/src/vapython/examples/__main__.py index 1e3f4b5d162f3d70ca8406bab315b9430b58c72b..a1937fede176c43094e5450c8a8e4007f29b0bf3 100644 --- a/src/vapython/examples/__main__.py +++ b/src/vapython/examples/__main__.py @@ -4,6 +4,17 @@ from pathlib import Path def main(): + """ + Main function to list and execute example scripts. + This function performs the following steps: + 1. Lists all Python files in the current directory that contain "example" in their name. + 2. If no command-line arguments are provided, it prints the list of example files and prompts the user to select one by index. + 3. If a command-line argument is provided, it uses that as the index of the example file to run. + 4. Validates the selected index and either exits, prints an error message, or imports and runs the selected example's main function. + Returns: + None + """ + current_path = Path(__file__).parent example_files = list(current_path.glob("*example*.py"))