Skip to content

Commit

Permalink
Add version option (#12)
Browse files Browse the repository at this point in the history
* Add version command

* Adding documnetation and linting
  • Loading branch information
pcortada-te authored Feb 27, 2025
1 parent 4fcec50 commit 579736a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ The ["I am starting from scratch" quick-start guide](<2.2. I am starting from sc
9. [`stacks surgery rename`](<docs/3.3.9. stacks surgery rename.md>)
10. [`stacks surgery move`](<docs/3.3.10. stacks surgery move.md>)
11. [`stacks surgery edit`](<docs/3.3.11. stacks surgery edit.md>)
12. [`stacks version`](<docs/3.3.12. stacks version.md>)
4. [Directory structure](<docs/3.4. Directory structure.md>)
5. [Special variables](<docs/3.5. Special variables.md>)
20 changes: 20 additions & 0 deletions docs/3.3.12. stacks version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# `stacks surgery edit`

## Usage
```
Usage: stacks version
Print the Stacks and Python version numbers
```

## Description

Print the Stacks and Python version numbers and exit

## Example

```shell
$ stacks version
Stacks 2.0.8
Python 3.12.8
```
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "stacks"
version = "2.0.7"
version = "2.0.8"
description = "Stacks, the Terraform code pre-processor"
readme = "README.md"
requires-python = ">=3.10"
Expand All @@ -9,9 +9,10 @@ dependencies = [
"cryptography>=43.0.3",
"deepmerge>=2.0",
"gitpython>=3.1.43",
"importlib>=1.0.4",
"jinja2>=3.1.4",
"packaging>=24.2",
"python-hcl2<6.0.0", # https://github.com/amplify-education/python-hcl2/issues/183
"python-hcl2<6.0.0", # https://github.com/amplify-education/python-hcl2/issues/183
"pyyaml>=6.0.2",
]

Expand Down
8 changes: 8 additions & 0 deletions src/stacks/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import importlib.metadata
import pathlib
import platform

import click

Expand All @@ -16,6 +18,12 @@ def cli():
pass


@cli.command()
def version():
print(f"Stacks {importlib.metadata.version('stacks')}")
print(f"Python {platform.python_version()}")


@cli.command(hidden=True) # hidden because it should not be used independently unless for advanced debugging purposes
def preinit():
cmd.preinit(ctx=cmd.Context())
Expand Down
12 changes: 10 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 579736a

Please sign in to comment.