options - Infernet Client
Description: Infernet Client Documentation

Skip to content

# Module: `options`

## `amount_option(f)`

Decorator to add a amount option to a command.

Source code in `src/infernet_client/cli/options.py`

    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    def amount_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add a amount option to a command."""
        return click.option(
            "-a",
            "--amount",
            required=True,
            type=str,
            help="Amount to approve for spending. Either provide a number i.e. 100 or a "
            "number and a denomination: i.e. '1 ether', '100 gwei', etc.",
        )(f)

## `input_option(f)`

Decorator to add an input option to a command.

Source code in `src/infernet_client/cli/options.py`

    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    def input_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add an input option to a command."""
        return click.option(
            "-i",
            "--input",
            required=False,
            type=click.File("r"),
            default="-",
            help=(
                "Input file to read the data from. "
                "Must be a JSON file. Skip or use '-' for stdin."
            ),
        )(f)

## `output_option(f)`

Decorator to add an output option to a command.

Source code in `src/infernet_client/cli/options.py`

    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    def output_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add an output option to a command."""
        return click.option(
            "-o",
            "--output",
            required=False,
            type=click.File("w"),
            default="-",
            help="Output file to write the result to. Skip or use '-' for stdout.",
        )(f)

## `output_result(result, output)`

Output result to the specified output.

If the result is a string, it will be output as is. Otherwise, it will be output as formatted JSON.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`result` | `Any` | Result to output | required
`output` | `IO[str]` | Output stream | required

Source code in `src/infernet_client/cli/options.py`

    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    def output_result(result: Any, output: IO[str]) -> None:
        """Output result to the specified output.

        If the result is a string, it will be output as is. Otherwise, it will be output as
        formatted JSON.

        Args:
            result (Any): Result to output
            output (IO[str]): Output stream
        """
        if isinstance(result, str):
            output.write(result)
        else:
            json.dump(result, output, indent=2)
        output.write("\n")

## `private_key_option(f)`

Decorator to add a private key option to a command.

Source code in `src/infernet_client/cli/options.py`

     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    def private_key_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add a private key option to a command."""
        return click.option(
            "-pk",
            "--private-key",
            envvar="PRIVATE_KEY",
            required=True,
            type=str,
            help="Private key. Can also set PRIVATE_KEY environment variable.",
        )(f)

## `router_url_option(f)`

Decorator to add a router URL option to a command.

Source code in `src/infernet_client/cli/options.py`

    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    def router_url_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add a router URL option to a command."""
        return click.option(
            "--url",
            envvar="ROUTER_URL",
            required=False,
            default="http://infernet-router.ritual.net",
            type=str,
            help="URL of the router. Can also set ROUTER_URL environment variable.",
        )(f)

## `rpc_url_option(f)`

Decorator to add an rpc url option to a command.

Source code in `src/infernet_client/cli/options.py`

    84
    85
    86
    87
    88
    89
    90
    91
    92
    def rpc_url_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add an rpc url option to a command."""
        return click.option(
            "--rpc-url",
            envvar="RPC_URL",
            required=True,
            type=str,
            help="RPC url. Can also set RPC_URL environment variable.",
        )(f)

## `token_option(f)`

Decorator to add a token address option to a command.

Source code in `src/infernet_client/cli/options.py`

    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    def token_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add a token address option to a command."""
        return click.option(
            "-t",
            "--token",
            required=False,
            type=str,
            default=ZERO_ADDRESS,
            help="Address of the token to approve for spending, defaults to zero address "
            "(native token).",
        )(f)

## `url_option(f)`

Decorator to add a URL option to a command.

Source code in `src/infernet_client/cli/options.py`

    12
    13
    14
    15
    16
    17
    18
    19
    20
    def url_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add a URL option to a command."""
        return click.option(
            "--url",
            envvar="SERVER_URL",
            required=True,
            type=str,
            help="URL of the server. Can also set SERVER_URL environment variable.",
        )(f)

## `wallet_option(f)`

Decorator to add a wallet address option to a command.

Source code in `src/infernet_client/cli/options.py`

    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    def wallet_option(f: GenericCallable) -> GenericCallable:
        """Decorator to add a wallet address option to a command."""
        return click.option(
            "-w",
            "--wallet",
            required=True,
            type=str,
            help="Address of the Infernet wallet, the owner of whom is approving the "
            "spender.",
        )(f)