Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,7 @@ def wallet_ask(

def wallet_list(
self,
wallet_name: Optional[str] = Options.wallet_name,
wallet_path: str = Options.wallet_path,
quiet: bool = Options.quiet,
verbose: bool = Options.verbose,
Expand All @@ -1898,7 +1899,13 @@ def wallet_list(
wallet = self.wallet_ask(
None, wallet_path, None, ask_for=[WO.PATH], validate=WV.NONE
)
return self._run_command(wallets.wallet_list(wallet.path, json_output))
return self._run_command(
wallets.wallet_list(
wallet.path,
json_output,
wallet_name=wallet_name,
)
)

def wallet_overview(
self,
Expand Down
18 changes: 16 additions & 2 deletions bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,13 +813,22 @@ async def wallet_history(wallet: Wallet):
console.print(table)


async def wallet_list(wallet_path: str, json_output: bool):
async def wallet_list(
wallet_path: str, json_output: bool, wallet_name: Optional[str] = None
):
"""Lists wallets."""
wallets = utils.get_coldkey_wallets_for_path(wallet_path)
print_verbose(f"Using wallets path: {wallet_path}")
if not wallets:
err_console.print(f"[red]No wallets found in dir: {wallet_path}[/red]")

if wallet_name:
wallets = [wallet for wallet in wallets if wallet.name == wallet_name]
if not wallets:
err_console.print(
f"[red]Wallet '{wallet_name}' not found in dir: {wallet_path}[/red]"
)

root = Tree("Wallets")
main_data_dict = {"wallets": []}
for wallet in wallets:
Expand Down Expand Up @@ -876,7 +885,12 @@ async def wallet_list(wallet_path: str, json_output: bool):

if not wallets:
print_verbose(f"No wallets found in path: {wallet_path}")
root.add("[bold red]No wallets found.")
message = (
"[bold red]No wallets found."
if not wallet_name
else f"[bold red]Wallet '{wallet_name}' not found."
)
root.add(message)
if json_output:
json_console.print(json.dumps(main_data_dict))
else:
Expand Down
Loading