27
27
28
28
@click .command (context_settings = {"ignore_unknown_options" : True })
29
29
@click .version_option (version = __version__ )
30
- @click .argument ("version_part" )
31
- @click .argument ("files" , nargs = - 1 , type = click .Path ())
30
+ @click .argument ("args" , nargs = - 1 , type = str )
32
31
@click .option (
33
32
"--config-file" ,
34
33
metavar = "FILE" ,
165
164
help = "List machine readable information" ,
166
165
)
167
166
def cli (
168
- version_part : str ,
169
- files : list ,
167
+ # version_part: str,
168
+ args : list ,
170
169
config_file : Optional [str ],
171
170
verbose : int ,
172
171
allow_dirty : Optional [bool ],
@@ -190,6 +189,8 @@ def cli(
190
189
"""
191
190
Change the version.
192
191
192
+ ARGS may contain any of the following:
193
+
193
194
VERSION_PART is the part of the version to increase, e.g. `minor` .
194
195
Valid values include those given in the `--serialize` / `--parse` option.
195
196
@@ -219,6 +220,14 @@ def cli(
219
220
220
221
found_config_file = find_config_file (config_file )
221
222
config = get_configuration (found_config_file , ** overrides )
223
+ if args :
224
+ if args [0 ] not in config .parts .keys ():
225
+ raise ValueError (f"Unknown version part: { args [0 ]} " )
226
+ version_part = args [0 ]
227
+ files = args [1 :]
228
+ else :
229
+ version_part = None
230
+ files = args
222
231
223
232
if show_list :
224
233
log_list (config , version_part , new_version )
@@ -240,10 +249,12 @@ def cli(
240
249
def log_list (config : Config , version_part : Optional [str ], new_version : Optional [str ]) -> None :
241
250
"""Output configuration with new version."""
242
251
ctx = get_context (config )
243
- version = config .version_config .parse (config .current_version )
244
- next_version = get_next_version (version , config , version_part , new_version )
245
- next_version_str = config .version_config .serialize (next_version , ctx )
252
+ if version_part :
253
+ version = config .version_config .parse (config .current_version )
254
+ next_version = get_next_version (version , config , version_part , new_version )
255
+ next_version_str = config .version_config .serialize (next_version , ctx )
256
+
257
+ click .echo (f"new_version={ next_version_str } " )
246
258
247
- click .echo (f"new_version={ next_version_str } " )
248
259
for key , value in config .dict (exclude = {"scm_info" , "parts" }).items ():
249
260
click .echo (f"{ key } ={ value } " )
0 commit comments