Commit 7f2da26
committed
feat: added --version flag
added the --version flag to the dotcat command-line tool that prints the version from the metadata, along with a test to verify it works correctly.
Here's what I did:
Fixed the import in __version__.py to correctly import the metadata module:
from importlib import metadata
__version__ = metadata.version('dotcat')
Added the --version flag to the argument parser in dotcat.py:
parser.add_argument(
"--version",
action="store_true",
help="Show version information",
)
Updated the run function to handle the --version flag:
if version_flag:
print(f"dotcat version {__version__}")
return
Updated the help text to include information about the --version flag.
Added a test for the --version flag in tests/test_exec.py:
def test_version_flag():
test_args = ["--version"]
captured_output = StringIO()
sys.stdout = captured_output
run(test_args)
sys.stdout = sys.__stdout__
actual_output = captured_output.getvalue().strip()
assert actual_output == f"dotcat version {__version__}"
All tests are now passing, confirming that the --version flag works correctly and displays the version from the metadata (currently 0.8.26).1 parent eb5199d commit 7f2da26
3 files changed
+36
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
101 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| |||
375 | 380 | | |
376 | 381 | | |
377 | 382 | | |
378 | | - | |
| 383 | + | |
379 | 384 | | |
380 | 385 | | |
381 | 386 | | |
382 | 387 | | |
383 | 388 | | |
384 | 389 | | |
385 | 390 | | |
386 | | - | |
| 391 | + | |
387 | 392 | | |
388 | 393 | | |
389 | 394 | | |
| |||
414 | 419 | | |
415 | 420 | | |
416 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
417 | 427 | | |
418 | 428 | | |
419 | 429 | | |
420 | 430 | | |
421 | 431 | | |
422 | 432 | | |
423 | 433 | | |
| 434 | + | |
424 | 435 | | |
425 | 436 | | |
426 | 437 | | |
| |||
449 | 460 | | |
450 | 461 | | |
451 | 462 | | |
452 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
453 | 466 | | |
454 | 467 | | |
455 | 468 | | |
456 | 469 | | |
457 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
458 | 475 | | |
459 | 476 | | |
460 | 477 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
109 | 121 | | |
110 | 122 | | |
111 | 123 | | |
| |||
0 commit comments