Skip to content

Commit 2f365ee

Browse files
committed
Add version command
1 parent 296e0ba commit 2f365ee

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

docs/warnet.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ parameters in <angle brackets>.
1111

1212
`warnet` commands are organized in a hierarchy of categories and subcommands.
1313

14+
Check the version of warnet using `warnet version`.
15+
1416
## API Commands
1517

1618
### `warnet auth`

src/warnet/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import click
2+
import importlib.metadata
23

34
from .admin import admin
45
from .bitcoin import bitcoin
@@ -17,6 +18,14 @@
1718
def cli():
1819
pass
1920

21+
@click.command()
22+
def version() -> None:
23+
"""Display the installed version of warnet"""
24+
try:
25+
version = importlib.metadata.version("warnet")
26+
click.echo(f"warnet version {version}")
27+
except importlib.metadata.PackageNotFoundError:
28+
click.echo("warnet version unknown (package not installed)")
2029

2130
cli.add_command(admin)
2231
cli.add_command(auth)
@@ -37,7 +46,7 @@ def cli():
3746
cli.add_command(status)
3847
cli.add_command(stop)
3948
cli.add_command(create)
40-
49+
cli.add_command(version)
4150

4251
if __name__ == "__main__":
4352
cli()

0 commit comments

Comments
 (0)