Skip to content

Commit

Permalink
Refactor module layout
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Nov 16, 2023
1 parent 4098527 commit 8c26e72
Show file tree
Hide file tree
Showing 9 changed files with 807 additions and 343 deletions.
386 changes: 386 additions & 0 deletions examples/bet.json

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions src/styx/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Command line interface for styx."""

import argparse
import json
import pathlib as pl

from styx.boutiques import model
from styx.compiler.core import compile_descriptor
from styx.compiler.settings import CompilerSettings


def _cli() -> None:
"""Command line interface for styx."""
parser = argparse.ArgumentParser(
prog="styx",
description="Styx is a command line tool Python wrapper code generator.",
)

parser.add_argument(
"input",
type=pl.Path,
help="Path to the input JSON Boutiques descriptor.",
)

parser.add_argument(
"-o",
"--output",
type=pl.Path,
help="Path to the output Python file.",
)

args = parser.parse_args()

path_descriptor: pl.Path = args.input
path_output: pl.Path | None = args.output

settings = CompilerSettings()

with open(path_descriptor, "r") as json_file:
json_data = json.load(json_file)

data = model.Tool(**json_data) # type: ignore

compiled_module = compile_descriptor(data, settings)

if path_output is None:
print(compiled_module)
else:
with open(path_output, "w") as py_file:
py_file.write(compiled_module)


if __name__ == "__main__":
_cli()
1 change: 1 addition & 0 deletions src/styx/compiler/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Boutiques to python compiler."""
Loading

0 comments on commit 8c26e72

Please sign in to comment.