-
Notifications
You must be signed in to change notification settings - Fork 74
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Typer allows multiple uses of the same option, and then just uses whichever was specified last. E.g. in btcli w balance --network ws://127.0.0.1:9945 --network local, it would use local and completely ignore the specified chain endpoint. This is usually not a big deal, but we have a number of aliases for network specifically:
"--network"
"--subtensor.network"
"--chain"
"--subtensor.chain_endpoint"
This can cause some confusion amongst people who are used to specifying --subtensor.network and --subtensor.chain_endpoint.
We can validate a single use of the commands with a callback, like so:
This does not work:
def validate_single_use(value: str, previous: str = None):
if previous is not None:
raise typer.BadParameter(f"Option '--network' was already used: {previous}")
return value
@app.command()
def balance(
network: str = typer.Option(None, "--network", callback=validate_single_use)
):
typer.echo(f"Using network: {network}")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request