Skip to content

Commit

Permalink
feat: 複数のデフォルト設定ファイルと短縮ヘルプオプションのサポートを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
kiarina committed Feb 9, 2025
1 parent 4053591 commit 0361c87
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - 2024-02-09

### Added
- Support for both `pydantic-config-builder.yaml` and `pydantic-config-builder.yml` as default configuration files
- Support for `-h` as an alternative to `--help` for displaying help message

## [0.2.0] - 2024-02-09

### Added
Expand Down
2 changes: 1 addition & 1 deletion pydantic_config_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
A tool to build YAML configurations by merging multiple files
"""

__version__ = "0.2.0"
__version__ = "0.3.0"
15 changes: 10 additions & 5 deletions pydantic_config_builder/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .config import ConfigModel


@click.command()
@click.command(context_settings={"help_option_names": ["-h", "--help"]})
@click.option(
"-c",
"--config",
Expand All @@ -25,11 +25,16 @@ def main(config: Path | None, verbose: bool) -> None:
"""Build YAML configurations by merging multiple files."""
# Use default config file if not specified
if config is None:
config = Path("pydantic_config_builder.yml")
if not config.exists():
# Try both .yaml and .yml extensions
for ext in [".yaml", ".yml"]:
config = Path(f"pydantic-config-builder{ext}")
if config.exists():
break
else:
raise click.ClickException(
"No configuration file specified and "
"pydantic_config_builder.yml not found in current directory"
"No configuration file specified and neither "
"pydantic-config-builder.yaml nor pydantic-config-builder.yml "
"found in current directory"
)

if verbose:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pydantic-config-builder"
version = "0.2.0"
version = "0.3.0"
description = "A tool to build YAML configurations by merging multiple files"
authors = ["kiarina <kiarinadawa@gmail.com>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_cli_default_config(temp_dir):
runner = CliRunner()
with runner.isolated_filesystem():
# Copy test files to current directory
Path("pydantic_config_builder.yml").write_text(
Path("pydantic-config-builder.yml").write_text(
(temp_dir / "pydantic_config_builder.yml").read_text()
)
Path("base.yaml").write_text((temp_dir / "base.yaml").read_text())
Expand Down

0 comments on commit 0361c87

Please sign in to comment.