Skip to content

Commit e77bab8

Browse files
committed
Update to Typer 0.1.0
- Closes #19 - Remove click-completion dependency - Add `--version` option - Update CLI tests to use typer CliRunner
1 parent 1cb886d commit e77bab8

File tree

6 files changed

+243
-148
lines changed

6 files changed

+243
-148
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# Unreleased
8+
- Update Typer dependency to 0.1.0 and remove click-completion dependency
9+
- Add a `--version` option to print the version of openapi-python-client and exit
10+
711
## 0.1.2 - 2020-03-16
812
- Improve handling of optional properties in generated `to_dict` function for models
913
- Add PEP 561 marker file (py.typed) to generated packages

openapi_python_client/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import json
55
import shutil
6+
from importlib.metadata import version
67
from pathlib import Path
78
from typing import Any, Dict, Optional
89

@@ -11,6 +12,8 @@
1112

1213
from .openapi_parser import OpenAPI, import_string_from_reference
1314

15+
__version__ = version(__package__)
16+
1417

1518
def _get_project_for_url_or_path(url: Optional[str], path: Optional[Path]) -> _Project:
1619
data_dict = _get_json(url=url, path=path)

openapi_python_client/cli.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@
66
app = typer.Typer()
77

88

9+
def _version_callback(value: bool):
10+
from openapi_python_client import __version__
11+
12+
if value:
13+
typer.echo(f"openapi-python-client version: {__version__}")
14+
raise typer.Exit()
15+
16+
17+
# noinspection PyUnusedLocal
918
@app.callback()
10-
def cli() -> None:
19+
def cli(
20+
version: bool = typer.Option(False, "--version", callback=_version_callback),
21+
) -> None:
1122
""" Generate a Python client from an OpenAPI JSON document """
1223
pass
1324

0 commit comments

Comments
 (0)