8000 refactor(cli): add back --version and remove subcommand required cons… · modlin/commitizen@8ae5d8b · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ae5d8b

Browse files
committed
refactor(cli): add back --version and remove subcommand required constraint
these changes will apply when move into 2.0
1 parent db0b1d5 commit 8ae5d8b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

commitizen/cli.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@
2020
"arguments": [
2121
{"name": "--debug", "action": "store_true", "help": "use debug mode"},
2222
{"name": ["-n", "--name"], "help": "use the given commitizen"},
23+
{
24+
"name": ["--version"],
25+
"action": "store_true",
26+
"help": "get the version of the installed commitizen",
27+
},
2328
],
2429
"subcommands": {
2530
"title": "commands",
26-
"required": True,
31+
# TODO: Add this constraint back in 2.0
32+
# "required": True,
2733
"commands": [
2834
{
2935
"name": "ls",
@@ -123,11 +129,22 @@ def main():
123129
if args.name:
124130
conf.update({"name": args.name})
125131

132+
if args.version:
133+
warnings.warn(
134+
"'cz --version' will be deprecated in next major version. "
135+
"Please use 'cz version' command from your scripts"
136+
)
137+
logging.getLogger("commitizen").setLevel(logging.DEBUG)
138+
126139
if args.debug:
127140
warnings.warn(
128141
"Debug will be deprecated in next major version. "
129142
"Please remove it from your scripts"
130143
)
131144
logging.getLogger("commitizen").setLevel(logging.DEBUG)
132145

133-
args.func(conf, vars(args))()
146+
# TODO: This try block can be removed after command is required in 2.0
147+
try:
148+
args.func(conf, vars(args))()
149+
except AttributeError:
150+
out.error("Command is required")

0 commit comments

Comments
 (0)
0