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
1 change: 1 addition & 0 deletions tests/toml_cli/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


def test_get_value(tmp_path: pathlib.Path):
"toml_cli.app"
test_toml_path = tmp_path / "test.toml"
test_toml_path.write_text(
"""
Expand Down
7 changes: 3 additions & 4 deletions toml_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import pathlib
import re
from typing import Optional

import tomlkit
import tomlkit.exceptions
Expand All @@ -24,9 +23,9 @@ def path_callback(value: pathlib.Path):

@app.command("get")
def get(
key: Optional[str] = typer.Argument(None),
key: str | None = typer.Argument(None),
toml_path: pathlib.Path = typer.Option(DEFAULT_TOML_PATH, callback=path_callback),
default: Optional[str] = typer.Option(None),
default: str | None = typer.Option(None),
):
"""Get a value from a toml file."""
toml_part = tomlkit.parse(toml_path.read_text())
Expand Down Expand Up @@ -65,7 +64,7 @@ def get(
typer.echo(f"error: key '{key_part}' not found", err=True)
raise typer.Exit(code=1) from err

typer.echo(toml_part.unwrap())
typer.echo(toml_part.unwrap() if hasattr(toml_part, "unwrap") else toml_part)


@app.command("set")
Expand Down
Loading