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
38 changes: 18 additions & 20 deletions fireblocks_cli/commands/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
DEFAULT_CONFIG,
)
from fireblocks_cli.utils.toml import save_toml
from tomlkit import document, table, inline_table, dumps


configure_app = typer.Typer()

Expand All @@ -32,28 +34,24 @@ def init():
# Create config.toml if it does not exist
config_file = get_config_file()
if not config_file.exists():
config = DEFAULT_CONFIG.copy()

# If credentials file exists, use its values to populate config
credentials_file = get_credentials_file()
if credentials_file.exists():
lines = credentials_file.read_text().splitlines()
for line in lines:
if "api_id" in line:
config["default"]["api_id"] = line.split("=")[-1].strip()
elif "api_secret_key" in line:
config["default"]["api_secret_key"] = line.split("=")[-1].strip()
typer.secho(
f"✅ Loaded credentials from: {credentials_file}",
fg=typer.colors.YELLOW,
)

# Save the populated config to file
save_toml(config, config_file)
typer.secho(f"✅ Created config.toml: {config_file}", fg=typer.colors.GREEN)
doc = document()

# [default]
default_section = table()
default_section.add("api_id", "get-api_id-from-fireblocks-dashboard")

secret_table = inline_table()
secret_table.add("type", "file")
secret_table.add("value", "~/.config/fireblocks-cli/keys/abcd.key")
secret_table.trailing_comma = True # ← インライン整形のオプション(任意)
default_section.add("api_secret_key", secret_table)

doc.add("default", default_section)
with config_file.open("w", encoding="utf-8") as f:
f.write(dumps(doc))
else:
typer.secho(
f" config.toml already exists: {config_file}", fg=typer.colors.YELLOW
f" config.toml already exists: {config_file}", fg=typer.colors.YELLOW
)

# Ensure ~/.config/fireblocks-cli/keys directory exists
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions poetry.lock.license

This file was deleted.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ readme = "README.md"
requires-python = ">=3.11,<3.14"
dependencies = [
"typer[all]>0.15.0",
"toml>0.10.0"
"toml>0.10.0",
"tomlkit (>=0.13.2,<0.14.0)"
]

[project.scripts]
Expand Down
3 changes: 2 additions & 1 deletion scripts/get_changed_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

# Author: Shohei KAMON <cameong@stir.network>

git status --porcelain | grep -v "^??" | cut -c4- | grep -v "\.txt$"
# exclude removed file: grep -v "^D"
git status --porcelain | grep -v "^??" | grep -v "^D " | cut -c4- | grep -v "\.txt$"