|
6 | 6 | from logging import error, getLevelName |
7 | 7 | from ast import literal_eval |
8 | 8 |
|
| 9 | +import platform |
9 | 10 | import sys |
10 | 11 |
|
11 | 12 |
|
@@ -75,15 +76,33 @@ def parse_array_string(value, enable_simple_split): |
75 | 76 | return value |
76 | 77 |
|
77 | 78 |
|
78 | | -def init_config(description, doc, version): |
| 79 | +def get_system_info_str(): |
| 80 | + system = platform.system() |
| 81 | + release = platform.release() |
| 82 | + machine = platform.machine() |
| 83 | + arch = platform.architecture()[0] # '64bit' or '32bit' |
| 84 | + |
| 85 | + return "{}-{} {} ({})".format(system, release, machine, arch) |
| 86 | + |
| 87 | + |
| 88 | +def get_python_info_str(): |
| 89 | + version = platform.python_version() |
| 90 | + branch, py_build_date = platform.python_build() |
| 91 | + return "Python-{} {} ({})".format(version, branch, py_build_date) |
| 92 | + |
| 93 | + |
| 94 | +def init_config(description, doc, version, date): |
79 | 95 | """ |
80 | 96 | 配置 |
81 | 97 | """ |
82 | 98 | global __cli_args |
83 | 99 | parser = ArgumentParser( |
84 | 100 | description=description, epilog=doc, formatter_class=RawTextHelpFormatter |
85 | 101 | ) |
86 | | - parser.add_argument("-v", "--version", action="version", version=version) |
| 102 | + sysinfo = get_system_info_str() |
| 103 | + pyinfo = get_python_info_str() |
| 104 | + version_str = "v{} ({})\n{}\n{}".format(version, date, pyinfo, sysinfo) |
| 105 | + parser.add_argument("-v", "--version", action="version", version=version_str) |
87 | 106 | parser.add_argument( |
88 | 107 | "-c", "--config", metavar="FILE", help="load config file [配置文件路径]" |
89 | 108 | ) |
|
0 commit comments