Skip to content

Commit 42331cb

Browse files
committed
Allow custom config path using env var
1 parent 2d82c63 commit 42331cb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bittensor_cli/cli.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,15 +655,22 @@ def __init__(self):
655655
self.event_loop = asyncio.new_event_loop()
656656

657657
self.config_base_path = os.path.expanduser(defaults.config.base_path)
658-
self.config_path = os.path.expanduser(defaults.config.path)
658+
self.config_path = os.getenv("BTCLI_CONFIG_PATH") or os.path.expanduser(
659+
defaults.config.path
660+
)
659661

660662
self.app = typer.Typer(
661663
rich_markup_mode="rich",
662664
callback=self.main_callback,
663665
epilog=_epilog,
664666
no_args_is_help=True,
665667
)
666-
self.config_app = typer.Typer(epilog=_epilog)
668+
self.config_app = typer.Typer(
669+
epilog=_epilog,
670+
help=f"Allows for getting/setting the config. "
671+
f"Default path for the config file is [{COLORS.G.ARG}]{defaults.config.path}[/{COLORS.G.ARG}]. "
672+
f"You can set your own with the env var [{COLORS.G.ARG}]BTCLI_CONFIG_PATH[/{COLORS.G.ARG}]",
673+
)
667674
self.wallet_app = typer.Typer(epilog=_epilog)
668675
self.stake_app = typer.Typer(epilog=_epilog)
669676
self.sudo_app = typer.Typer(epilog=_epilog)
@@ -1497,6 +1504,8 @@ def get_config(self):
14971504
Column("[bold white]Value", style="gold1"),
14981505
Column("", style="medium_purple"),
14991506
box=box.SIMPLE_HEAD,
1507+
title=f"[{COLORS.G.HEADER}]BTCLI Config[/{COLORS.G.HEADER}]: "
1508+
f"[{COLORS.G.ARG}]{self.config_path}[/{COLORS.G.ARG}]",
15001509
)
15011510

15021511
for key, value in self.config.items():

0 commit comments

Comments
 (0)