|
3 | 3 | import sys |
4 | 4 | import logging |
5 | 5 | import argparse |
| 6 | +import warnings |
6 | 7 | from decli import cli |
7 | 8 | from pathlib import Path |
8 | 9 | from configparser import RawConfigParser, NoSectionError |
9 | | -from commitizen.application import Application |
10 | | -from commitizen import deafults |
| 10 | +from commitizen import deafults, commands, out |
| 11 | +from commitizen.__version__ import __version__ |
11 | 12 |
|
12 | 13 |
|
13 | 14 | logger = logging.getLogger(__name__) |
|
21 | 22 | "formatter_class": argparse.RawDescriptionHelpFormatter, |
22 | 23 | "arguments": [ |
23 | 24 | {"name": "--debug", "action": "store_true", "help": "use debug mode"}, |
24 | | - { |
25 | | - "name": ["-n", "--name"], |
26 | | - "default": deafults.NAME, |
27 | | - "help": "use the given commitizen", |
28 | | - }, |
| 25 | + {"name": ["-n", "--name"], "help": "use the given commitizen"}, |
29 | 26 | { |
30 | 27 | "name": ["--version"], |
31 | 28 | "action": "store_true", |
|
38 | 35 | { |
39 | 36 | "name": "ls", |
40 | 37 | "help": "show available commitizens", |
41 | | - "func": lambda app: app.detected_cz, |
| 38 | + "func": commands.ListCz, |
42 | 39 | }, |
43 | 40 | { |
44 | 41 | "name": ["commit", "c"], |
45 | 42 | "help": "create new commit", |
46 | | - "func": lambda app: app.cz.run, |
| 43 | + "func": commands.Commit, |
47 | 44 | }, |
48 | 45 | { |
49 | 46 | "name": "example", |
50 | 47 | "help": "show commit example", |
51 | | - "func": lambda app: app.cz.show_example, |
| 48 | + "func": commands.Example, |
52 | 49 | }, |
53 | 50 | { |
54 | 51 | "name": "info", |
55 | 52 | "help": "show information about the cz", |
56 | | - "func": lambda app: app.cz.show_info, |
57 | | - }, |
58 | | - { |
59 | | - "name": "schema", |
60 | | - "help": "show commit schema", |
61 | | - "func": lambda app: app.cz.show_schema, |
| 53 | + "func": commands.Info, |
62 | 54 | }, |
| 55 | + {"name": "schema", "help": "show commit schema", "func": commands.Schema}, |
63 | 56 | ], |
64 | 57 | }, |
65 | 58 | } |
@@ -106,16 +99,19 @@ def main(): |
106 | 99 | raise SystemExit(1) |
107 | 100 |
|
108 | 101 | args = parser.parse_args() |
109 | | - app = Application(**config) |
110 | 102 |
|
111 | 103 | if args.name: |
112 | | - app.name = args.name |
| 104 | + config.update({"name": args.name}) |
113 | 105 |
|
114 | 106 | if args.debug: |
| 107 | + warnings.warn( |
| 108 | + "Debug will be deprecated in next major version. " |
| 109 | + "Please remove it from your scripts" |
| 110 | + ) |
115 | 111 | logging.getLogger("commitizen").setLevel(logging.DEBUG) |
116 | 112 |
|
117 | 113 | if args.version: |
118 | | - logger.info(app.version) |
119 | | - sys.exit(0) |
| 114 | + out.line(__version__) |
| 115 | + raise SystemExit() |
120 | 116 |
|
121 | | - args.func(app)(args) |
| 117 | + args.func(config)(args) |
0 commit comments