|
2 | 2 |
|
3 | 3 | import argparse |
4 | 4 | import logging |
| 5 | +import platform |
5 | 6 | import sys |
6 | 7 | from copy import deepcopy |
7 | 8 | from functools import partial |
|
13 | 14 | from decli import cli |
14 | 15 |
|
15 | 16 | from commitizen import commands, config, out, version_schemes |
| 17 | +from commitizen.__version__ import __version__ |
16 | 18 | from commitizen.defaults import DEFAULT_SETTINGS |
17 | 19 | from commitizen.exceptions import ( |
18 | 20 | CommitizenException, |
@@ -103,6 +105,16 @@ def __call__( |
103 | 105 | "required": False, |
104 | 106 | "help": "Comma-separated error codes that won't raise error, e.g., cz -nr 1,2,3 bump. See codes at https://commitizen-tools.github.io/commitizen/exit_codes/", |
105 | 107 | }, |
| 108 | + { |
| 109 | + "name": ["-v", "--version"], |
| 110 | + "action": "store_true", |
| 111 | + "help": "Show the version of the installed commitizen", |
| 112 | + }, |
| 113 | + { |
| 114 | + "name": ["--report"], |
| 115 | + "action": "store_true", |
| 116 | + "help": "Show system information for reporting bugs", |
| 117 | + }, |
106 | 118 | ], |
107 | 119 | "subcommands": { |
108 | 120 | "title": "commands", |
@@ -643,6 +655,18 @@ def main() -> None: |
643 | 655 | parser.print_help(sys.stderr) |
644 | 656 | raise ExpectedExit() |
645 | 657 |
|
| 658 | + # TODO(bearomorphism): mark `cz version --commitizen` as deprecated after `cz version` feature is stable |
| 659 | + if "--version" in sys.argv: |
| 660 | + out.write(__version__) |
| 661 | + raise ExpectedExit() |
| 662 | + |
| 663 | + # TODO(bearomorphism): mark `cz version --report` as deprecated after `cz version` feature is stable |
| 664 | + if "--report" in sys.argv: |
| 665 | + out.write(f"Commitizen Version: {__version__}") |
| 666 | + out.write(f"Python Version: {sys.version}") |
| 667 | + out.write(f"Operating System: {platform.system()}") |
| 668 | + raise ExpectedExit() |
| 669 | + |
646 | 670 | # This is for the command required constraint in 2.0 |
647 | 671 | try: |
648 | 672 | args, unknown_args = parser.parse_known_args() |
|
0 commit comments