Skip to content

Manage

Command-line interface.

sdl(file, output=<typer.models.OptionInfo object at 0x7f568f49a790>)

Generate SDL aka GraphQL schema from ADFH file.

Parameters:

Name Type Description Default
file str

Path to ADFH file.

required
output str

If --output is used, it will save it in file.

<typer.models.OptionInfo object at 0x7f568f49a790>
Source code in ihsan/manage.py
@app.command("sdl")
def sdl(
    file: str,
    output: str = typer.Option(None, help="save output into a file."),
) -> None:
    """Generate SDL aka GraphQL schema from ADFH file.

    Args:
        file: Path to ADFH file.
        output: If --output is used, it will save it in file.
    """
    console = Console()
    data = read_adfh_file(file=file)

    if type(data) == str:
        console.print(data, style="bold red")

    else:
        ihsan_type = IhsanType(**data)  # type: ignore
        sdl_output = to_sdl(schema=ihsan_type)
        if output:
            typer.confirm(
                f"The output will be saved in {output}, are you sure?", abort=True
            )
            with open(output, "w") as output_file:
                output_file.write(sdl_output)
        else:
            console.print(sdl_output, style="bold green")
        console.print(
            "Use -> https://app.graphqleditor.com/ to test the schema :)",
            style="bold blue",
        )

version()

Show project Version.

Source code in ihsan/manage.py
@app.command()
def version() -> None:
    """Show project Version."""
    console = Console()
    project_name = "Ihsan"
    console.print(f"{project_name} Version: {__version__}", style="bold green")

Last update: 2020-11-23
Authors: Mohamed Nesredin