Skip to content

Commit 1b45851

Browse files
committed
add --version support
1 parent 14b1385 commit 1b45851

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

airbyte_cdk/cli/airbyte_cdk/__init__.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
```bash
1010
airbyte-cdk --help
11+
airbyte-cdk --version
1112
airbyte-cdk connector --help
1213
airbyte-cdk manifest --help
1314
```
@@ -38,24 +39,45 @@
3839

3940
from typing import cast
4041

41-
import click
42+
import rich_click as click
4243

4344
from airbyte_cdk.cli.airbyte_cdk._connector import connector_cli_group
45+
from airbyte_cdk.cli.airbyte_cdk._image import image_cli_group
4446
from airbyte_cdk.cli.airbyte_cdk._manifest import manifest_cli_group
47+
from airbyte_cdk.cli.airbyte_cdk._version import print_version
4548

4649

4750
@click.group(
4851
help=cast(str, __doc__).replace("\n", "\n\n"), # Workaround to format help text correctly
52+
invoke_without_command=True,
4953
)
50-
def cli() -> None:
54+
@click.option(
55+
"--version",
56+
is_flag=True,
57+
help="Show the version of the Airbyte CDK.",
58+
)
59+
@click.pass_context
60+
def cli(
61+
ctx: click.Context,
62+
version: bool,
63+
) -> None:
5164
"""Airbyte CDK CLI.
5265
5366
Help text is provided from the file-level docstring.
5467
"""
68+
if version:
69+
print_version(short=False)
70+
ctx.exit()
71+
72+
if ctx.invoked_subcommand is None:
73+
# If no subcommand is provided, show the help message.
74+
click.echo(ctx.get_help())
75+
ctx.exit()
5576

5677

5778
cli.add_command(connector_cli_group)
5879
cli.add_command(manifest_cli_group)
80+
cli.add_command(image_cli_group)
5981

6082

6183
if __name__ == "__main__":
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
2+
"""Version information for the Airbyte CDK CLI."""
3+
4+
from airbyte_cdk import __version__
5+
6+
7+
def print_version(short: bool = False) -> None:
8+
"""Print the version of the Airbyte CDK CLI."""
9+
10+
if short:
11+
print(__version__)
12+
else:
13+
print(f"Airbyte CDK version: {__version__}")

0 commit comments

Comments
 (0)