src/basilisp/cli.py
def run(  # pylint: disable=too-many-arguments
    file_or_code,
    code,
    in_ns,
    use_var_indirection,
    warn_on_shadowed_name,
    warn_on_shadowed_var,
    warn_on_var_indirection,
):
    """Run a Basilisp script or a line of code, if it is provided."""
    basilisp.init()
    ctx = compiler.CompilerContext(
        filename=CLI_INPUT_FILE_PATH
        if code
        else (
            STDIN_INPUT_FILE_PATH if file_or_code == STDIN_FILE_NAME else file_or_code
        ),
        opts={
            compiler.WARN_ON_SHADOWED_NAME: warn_on_shadowed_name,
            compiler.WARN_ON_SHADOWED_VAR: warn_on_shadowed_var,
            compiler.USE_VAR_INDIRECTION: use_var_indirection,
            compiler.WARN_ON_VAR_INDIRECTION: warn_on_var_indirection,
        },
    )
    eof = object()

    with runtime.ns_bindings(in_ns) as ns:
        if code:
            print(runtime.lrepr(eval_str(file_or_code, ctx, ns.module, eof)))
        elif file_or_code == STDIN_FILE_NAME:
            print(
                runtime.lrepr(
                    eval_stream(click.get_text_stream("stdin"), ctx, ns.module)
                )
            )
        else:
            print(runtime.lrepr(eval_file(file_or_code, ctx, ns.module)))
def run(  # pylint: disable=too-many-arguments
    file_or_code,
    code,
    in_ns,
    use_var_indirection,
    warn_on_shadowed_name,
    warn_on_shadowed_var,
    warn_on_var_indirection,
):
    """Run a Basilisp script or a line of code, if it is provided."""
    basilisp.init()
    ctx = compiler.CompilerContext(
        filename=CLI_INPUT_FILE_PATH
        if code
        else (
            STDIN_INPUT_FILE_PATH if file_or_code == STDIN_FILE_NAME else file_or_code
        ),
        opts={
            compiler.WARN_ON_SHADOWED_NAME: warn_on_shadowed_name,
            compiler.WARN_ON_SHADOWED_VAR: warn_on_shadowed_var,
            compiler.USE_VAR_INDIRECTION: use_var_indirection,
            compiler.WARN_ON_VAR_INDIRECTION: warn_on_var_indirection,
        },
    )
    eof = object()

    with runtime.ns_bindings(in_ns) as ns:
        if code:
            print(runtime.lrepr(eval_str(file_or_code, ctx, ns.module, eof)))
        elif file_or_code == STDIN_FILE_NAME:
            print(
                runtime.lrepr(
                    eval_stream(click.get_text_stream("stdin"), ctx, ns.module)
                )
            )
        else:
            print(runtime.lrepr(eval_file(file_or_code, ctx, ns.module)))
Run a Basilisp script or a line of code, if it is provided.