diff --git a/fireblocks_cli/commands/configure.py b/fireblocks_cli/commands/configure.py index 57a81d4..216b779 100644 --- a/fireblocks_cli/commands/configure.py +++ b/fireblocks_cli/commands/configure.py @@ -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() @@ -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 diff --git a/poetry.lock b/poetry.lock index dc04916..c036bdc 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1460,7 +1460,7 @@ version = "0.13.2" description = "Style preserving TOML library" optional = false python-versions = ">=3.8" -groups = ["dev"] +groups = ["main", "dev"] files = [ {file = "tomlkit-0.13.2-py3-none-any.whl", hash = "sha256:7a974427f6e119197f670fbbbeae7bef749a6c14e793db934baefc1b5f03efde"}, {file = "tomlkit-0.13.2.tar.gz", hash = "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79"}, @@ -1597,4 +1597,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.11,<3.14" -content-hash = "1143c92c2cdf134a28941dea577e3e4f1f4d7f9672f9313a2708b0d304df0dd3" +content-hash = "4d64f5580254d70c4089155b6da6a8af45b8a03d85f1dad177cb9027d67d9e0c" diff --git a/poetry.lock.license b/poetry.lock.license deleted file mode 100644 index 7007309..0000000 --- a/poetry.lock.license +++ /dev/null @@ -1,4 +0,0 @@ -SPDX-FileCopyrightText: 2025 Ethersecurity Inc. - -SPDX-License-Identifier: MPL-2.0 -# Author: Shohei KAMON diff --git a/pyproject.toml b/pyproject.toml index 13ef696..05c45ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] diff --git a/scripts/get_changed_files.sh b/scripts/get_changed_files.sh index 034a11f..19050ba 100644 --- a/scripts/get_changed_files.sh +++ b/scripts/get_changed_files.sh @@ -6,4 +6,5 @@ # Author: Shohei KAMON -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$"