Skip to content

cli

Classes:

Functions:

CustomHelpFormatter

CustomHelpFormatter(
    prog: str,
    indent_increment: int = 2,
    max_help_position: int = 4,
    width: Optional[int] = None,
    **kwargs: Any,
)

Bases: RawTextHelpFormatter

Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail.

Source code in src/arx/cli.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def __init__(
    self,
    prog: str,
    indent_increment: int = 2,
    max_help_position: int = 4,
    width: Optional[int] = None,
    **kwargs: Any,
) -> None:
    super().__init__(
        prog,
        indent_increment=indent_increment,
        max_help_position=max_help_position,
        width=width,
        **kwargs,
    )

app

app() -> None
Source code in src/arx/cli.py
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
def app() -> None:
    """
    title: Run the application.
    """
    args_parser = get_args()
    args = args_parser.parse_args()

    if args.input_files and args.input_files[0] == "run":
        args.run = True
        args.input_files = args.input_files[1:]

    if args.version:
        return show_version()

    arx = ArxMain()
    return arx.run(**dict(args._get_kwargs()))

get_args

get_args() -> ArgumentParser
Source code in src/arx/cli.py
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
def get_args() -> argparse.ArgumentParser:
    """
    title: Get the CLI arguments.
    returns:
      type: argparse.ArgumentParser
    """
    parser = argparse.ArgumentParser(
        prog="arx",
        description=(
            "Arx is a compiler that uses the power of llvm to bring a modern "
            "infra-structure."
        ),
        epilog=(
            "If you have any problem, open an issue at: "
            "https://github.com/arxlang/arx"
        ),
        add_help=True,
        formatter_class=CustomHelpFormatter,
    )
    parser.add_argument(
        "input_files",
        nargs="*",
        type=str,
        help="The input file",
    )
    parser.add_argument(
        "--version",
        action="store_true",
        help="Show the version of the installed MakIm tool.",
    )

    parser.add_argument(
        "--output-file",
        type=str,
        help="The output file",
    )

    parser.add_argument(
        "--lib",
        dest="is_lib",
        action="store_true",
        help="build source code as library",
    )

    parser.add_argument(
        "--show-ast",
        action="store_true",
        help="Show the AST for the input source code",
    )

    parser.add_argument(
        "--show-tokens",
        action="store_true",
        help="Show the tokens for the input source code",
    )

    parser.add_argument(
        "--show-llvm-ir",
        action="store_true",
        help="Show the LLVM IR for the input source code",
    )

    parser.add_argument(
        "--shell",
        action="store_true",
        help="Open Arx in a shell prompt",
    )

    parser.add_argument(
        "--run",
        action="store_true",
        help="Build and run the compiled binary.",
    )
    parser.add_argument(
        "--link-mode",
        type=str,
        choices=("auto", "pie", "no-pie"),
        default="auto",
        help=(
            "Set executable link mode: auto (toolchain default), "
            "pie, or no-pie."
        ),
    )

    return parser

show_version

show_version() -> None
Source code in src/arx/cli.py
125
126
127
128
129
def show_version() -> None:
    """
    title: Show the application version.
    """
    print(__version__)