Skip to content

Commit 080073d

Browse files
authored
Merge pull request opentensor#739 from opentensor/update/support-case-insentitive-claim
Support case insensitive claim commands
2 parents 2d92d83 + acfa705 commit 080073d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

bittensor_cli/cli.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,22 @@ def is_valid_ss58_address_param(address: Optional[str]) -> Optional[str]:
149149
return address
150150

151151

152+
def validate_claim_type(value: Optional[str]) -> Optional[claim_stake.ClaimType]:
153+
"""
154+
Validates the claim type argument, allowing case-insensitive input.
155+
"""
156+
if value is None:
157+
return None
158+
159+
try:
160+
for member in claim_stake.ClaimType:
161+
if member.value.lower() == value.lower():
162+
return member
163+
return claim_stake.ClaimType(value)
164+
except ValueError:
165+
raise typer.BadParameter(f"'{value}' is not one of 'Keep', 'Swap'.")
166+
167+
152168
class Options:
153169
"""
154170
Re-usable typer args
@@ -5616,9 +5632,10 @@ def stake_wizard(
56165632
def stake_set_claim_type(
56175633
self,
56185634
claim_type: Annotated[
5619-
Optional[claim_stake.ClaimType],
5635+
Optional[str],
56205636
typer.Argument(
56215637
help="Claim type: 'Keep' or 'Swap'. If omitted, user will be prompted.",
5638+
callback=validate_claim_type,
56225639
),
56235640
] = None,
56245641
netuids: Optional[str] = typer.Option(

0 commit comments

Comments
 (0)