Skip to content

Commit 579736a

Browse files
authored
Add version option (#12)
* Add version command * Adding documnetation and linting
1 parent 4fcec50 commit 579736a

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ The ["I am starting from scratch" quick-start guide](<2.2. I am starting from sc
5757
9. [`stacks surgery rename`](<docs/3.3.9. stacks surgery rename.md>)
5858
10. [`stacks surgery move`](<docs/3.3.10. stacks surgery move.md>)
5959
11. [`stacks surgery edit`](<docs/3.3.11. stacks surgery edit.md>)
60+
12. [`stacks version`](<docs/3.3.12. stacks version.md>)
6061
4. [Directory structure](<docs/3.4. Directory structure.md>)
6162
5. [Special variables](<docs/3.5. Special variables.md>)

docs/3.3.12. stacks version.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# `stacks surgery edit`
2+
3+
## Usage
4+
```
5+
Usage: stacks version
6+
7+
Print the Stacks and Python version numbers
8+
```
9+
10+
## Description
11+
12+
Print the Stacks and Python version numbers and exit
13+
14+
## Example
15+
16+
```shell
17+
$ stacks version
18+
Stacks 2.0.8
19+
Python 3.12.8
20+
```

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "stacks"
3-
version = "2.0.7"
3+
version = "2.0.8"
44
description = "Stacks, the Terraform code pre-processor"
55
readme = "README.md"
66
requires-python = ">=3.10"
@@ -9,9 +9,10 @@ dependencies = [
99
"cryptography>=43.0.3",
1010
"deepmerge>=2.0",
1111
"gitpython>=3.1.43",
12+
"importlib>=1.0.4",
1213
"jinja2>=3.1.4",
1314
"packaging>=24.2",
14-
"python-hcl2<6.0.0", # https://github.com/amplify-education/python-hcl2/issues/183
15+
"python-hcl2<6.0.0", # https://github.com/amplify-education/python-hcl2/issues/183
1516
"pyyaml>=6.0.2",
1617
]
1718

src/stacks/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import importlib.metadata
12
import pathlib
3+
import platform
24

35
import click
46

@@ -16,6 +18,12 @@ def cli():
1618
pass
1719

1820

21+
@cli.command()
22+
def version():
23+
print(f"Stacks {importlib.metadata.version('stacks')}")
24+
print(f"Python {platform.python_version()}")
25+
26+
1927
@cli.command(hidden=True) # hidden because it should not be used independently unless for advanced debugging purposes
2028
def preinit():
2129
cmd.preinit(ctx=cmd.Context())

uv.lock

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)