File tree 4 files changed +273
-35
lines changed
4 files changed +273
-35
lines changed Original file line number Diff line number Diff line change @@ -805,12 +805,14 @@ def run_update(self) -> None:
805
805
# review the diff before committing; so we can safely avoid
806
806
# asking for confirmation
807
807
raise UserMessageError ("Enable overwrite to update a subproject." )
808
+ self ._print_message (self .template .message_before_update )
808
809
if not self .quiet :
809
810
# TODO Unify printing tools
810
811
print (
811
812
f"Updating to template version { self .template .version } " , file = sys .stderr
812
813
)
813
814
self ._apply_update ()
815
+ self ._print_message (self .template .message_after_update )
814
816
815
817
def _apply_update (self ):
816
818
subproject_top = Path (
Original file line number Diff line number Diff line change @@ -309,11 +309,21 @@ def message_after_copy(self) -> str:
309
309
"""Get message to print after copy action specified in the template."""
310
310
return self .config_data .get ("message_after_copy" , "" )
311
311
312
+ @cached_property
313
+ def message_after_update (self ) -> str :
314
+ """Get message to print after update action specified in the template."""
315
+ return self .config_data .get ("message_after_update" , "" )
316
+
312
317
@cached_property
313
318
def message_before_copy (self ) -> str :
314
319
"""Get message to print before copy action specified in the template."""
315
320
return self .config_data .get ("message_before_copy" , "" )
316
321
322
+ @cached_property
323
+ def message_before_update (self ) -> str :
324
+ """Get message to print before update action specified in the template."""
325
+ return self .config_data .get ("message_before_update" , "" )
326
+
317
327
@cached_property
318
328
def metadata (self ) -> AnyByStrDict :
319
329
"""Get template metadata.
Original file line number Diff line number Diff line change @@ -1028,6 +1028,28 @@ The message is suppressed when Copier is run in [quiet mode][quiet].
1028
1028
2. Read "CONTRIBUING.md" and start coding.
1029
1029
` ` `
1030
1030
1031
+ # ## `message_after_update`
1032
+
1033
+ - Format : ` str`
1034
+ - CLI flags : N/A
1035
+ - Default value : ` ""`
1036
+
1037
+ Like [`message_after_copy`][message_after_copy] but printed after
1038
+ [_updating_](updating.md) a project.
1039
+
1040
+ !!! example
1041
+
1042
+ ` ` ` yaml title="copier.yml"
1043
+ project_name:
1044
+ type: str
1045
+ help: An awesome project needs an awesome name. Tell me yours.
1046
+
1047
+ _message_after_update: |
1048
+ Your project "{{ project_name }}" has been updated successfully!
1049
+ In case there are any conflicts, please resolve them. Then,
1050
+ you're done.
1051
+ ` ` `
1052
+
1031
1053
# ## `message_before_copy`
1032
1054
1033
1055
- Format : ` str`
@@ -1051,6 +1073,29 @@ Like [`message_after_copy`][message_after_copy] but printed _before_
1051
1073
generate a tailored project for you.
1052
1074
` ` `
1053
1075
1076
+ # ## `message_before_update`
1077
+
1078
+ - Format : ` str`
1079
+ - CLI flags : N/A
1080
+ - Default value : ` ""`
1081
+
1082
+ Like [`message_before_copy`][message_after_copy] but printed before
1083
+ [_updating_](updating.md) a project.
1084
+
1085
+ !!! example
1086
+
1087
+ ` ` ` yaml title="copier.yml"
1088
+ project_name:
1089
+ type: str
1090
+ help: An awesome project needs an awesome name. Tell me yours.
1091
+
1092
+ _message_before_update: |
1093
+ Thanks for updating your project using our template.
1094
+
1095
+ You'll be asked a series of questions whose answers are pre-populated
1096
+ with previously entered values. Feel free to change them as needed.
1097
+ ` ` `
1098
+
1054
1099
# ## `migrations`
1055
1100
1056
1101
- Format : ` List[dict]`
You can’t perform that action at this time.
0 commit comments