-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from radifar/entry-point
Entry point
- Loading branch information
Showing
10 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import typer | ||
from rich.console import Console | ||
|
||
from deemian.engine.builder import DeemianData | ||
from deemian.engine.processor import parser, InstructionTransformer | ||
from deemian.engine.director import director | ||
|
||
|
||
console = Console() | ||
app = typer.Typer() | ||
|
||
|
||
@app.command(short_help="run deemian script") | ||
def run(script_name: str): | ||
console.print(f"[bold magenta]Running {script_name}[/bold magenta]") | ||
with open(script_name) as f: | ||
text = f.read() | ||
|
||
command_tree = parser(text) | ||
transformer = InstructionTransformer() | ||
command_tree = transformer.transform(command_tree) | ||
|
||
deemian_data = DeemianData() | ||
director(command_tree, deemian_data) | ||
|
||
|
||
# one command one callback, just a temporary helper command | ||
# delete this when there are multiple commands | ||
# https://typer.tiangolo.com/tutorial/commands/one-or-multiple/ | ||
@app.callback() | ||
def callback(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
# from deemian import deemian | ||
from unittest.mock import patch | ||
|
||
from typer.testing import CliRunner | ||
|
||
from deemian.deemian import app | ||
|
||
|
||
runner = CliRunner() | ||
|
||
|
||
def test_app(): | ||
with patch("deemian.deemian.director"): | ||
result = runner.invoke(app, ["run", "tests/data/n1-oseltamivir-5nzn.txt"]) | ||
assert result.exit_code == 0 |