Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
manmolecular authored Aug 9, 2020
1 parent ef04601 commit 8b56d5b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ _First of all: provide some arguments in the `main.py` file to collect informati

To run the framework:
```bash
python3 main.py
python3 main.py example_scenario.yaml
```
To run the tests:
```bash
chmod +x run_tests.sh
./run_tests.sh
```
_or you can run them like this, of course:_
```bash
python3 -m unittest discover -v
```

## Running as a separated module
Basic:
```python3
Expand Down Expand Up @@ -51,10 +48,11 @@ Use the following structure:
2. Provide the following structure of your script directory:
```
your_script_name
├── __init__.py - use this module to set the default parent directory (you can copy this file from any other script)
├── __main__.py - use this module to provide some basic interface to use your script as a module (the same as if __name__ == "__main__")
├── module.py - use this module to describe the basic logic of your module (you can import it in the __main__.py to provide interface)
└── test_module.py - use this module for unittest tests
├── requirements.txt - provide required libraries
├── __init__.py - use this module to set the default parent directory (you can copy this file from any other script)
├── __main__.py - use this module to provide some basic interface to use your script as a module (the same as if __name__ == "__main__")
├── module.py - use this module to describe the basic logic of your module (you can import it in the __main__.py to provide interface)
└── test_module.py - use this module for unittest tests
```
3. Create the `__init__.py` file. An example of the `__init__.py` boilerplate structure can be seen below:
```python3
Expand Down Expand Up @@ -103,6 +101,9 @@ class Runner(OsintRunner):
"""
Basic script example
"""

# Define required arguments here
required = ["my_argument"]

def __init__(self, logger: str = __name__):
"""
Expand All @@ -114,6 +115,7 @@ class Runner(OsintRunner):
"""
super(Runner, self).__init__(logger)

# Validate input arguments (if you need some validation)
@validate_kwargs(PossibleKeys.KEYS)
def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error:
"""
Expand All @@ -126,6 +128,7 @@ class Runner(OsintRunner):
:return: ScriptResponse message (error or success)
"""
argument = kwargs.get("my_argument", "Arguments were not provided!")
...
return ScriptResponse.success(message=f"Script finished with argument {argument}")
```
6. For `test_module.py` you can use any required tests (as you wish). A test case for your module is required to keep the project clean.

0 comments on commit 8b56d5b

Please sign in to comment.