@@ -24,9 +24,16 @@ public abstract partial class CommandProvider<T>
2424 /// <summary>
2525 /// Runs the add command.
2626 /// </summary>
27- /// <param name="statusContext">The status context for interacting with <see cref="AnsiConsole.Status"/>.</param>
28- /// <param name="replace">A value indicating whether to replace existing entries.</param>
29- protected virtual void RunAdd ( StatusContext statusContext , bool replace )
27+ /// <param name="statusContext">
28+ /// The status context for interacting with <see cref="AnsiConsole.Status"/>.
29+ /// </param>
30+ /// <param name="replace">
31+ /// A value indicating whether to replace existing entries.
32+ /// </param>
33+ /// <param name="continueOnError">
34+ /// A value indicating whether to continue adding files if an error occurs.
35+ /// </param>
36+ protected virtual void RunAdd ( StatusContext statusContext , bool replace , bool continueOnError )
3037 {
3138 if ( Bundle == null )
3239 {
@@ -41,7 +48,8 @@ protected virtual void RunAdd(StatusContext statusContext, bool replace)
4148
4249 statusContext . Status ( "[yellow]Adding Files[/]" ) ;
4350
44- _ = Parallel . ForEach ( Utilities . SafeEnumerateFiles ( Bundle . RootPath , "*" ) , file =>
51+ bool errorOccurred = false ;
52+ _ = Parallel . ForEach ( Utilities . SafeEnumerateFiles ( Bundle . RootPath , "*" ) , ( file , state ) =>
4553 {
4654 if ( file == Bundle . BundlePath ) return ;
4755 var entryName = Manifest . GetNormalizedEntryName ( Path . GetRelativePath ( Bundle . RootPath , file ) ) ;
@@ -68,10 +76,29 @@ protected virtual void RunAdd(StatusContext statusContext, bool replace)
6876 }
6977 catch ( Exception ex )
7078 {
79+ errorOccurred = true ;
80+
7181 AnsiConsole . MarkupLine ( $ "[{ Color . Red } ]Error:[/] { entryName } ({ ex . GetType ( ) . Name } : { ex . Message } )") ;
82+
83+ if ( ! continueOnError )
84+ {
85+ state . Stop ( ) ;
86+ }
7287 }
7388 } ) ;
7489
90+ if ( errorOccurred )
91+ {
92+ AnsiConsole . WriteLine ( ) ;
93+ AnsiConsole . MarkupLine ( "[red]One or more errors occurred, check the console output or logs for more information[/]" ) ;
94+
95+ if ( ! continueOnError )
96+ {
97+ AnsiConsole . MarkupLine ( "[red]No changes were made to the bundle[/]" ) ;
98+ return ;
99+ }
100+ }
101+
75102 statusContext . Status ( "[yellow]Saving Bundle[/]" ) ;
76103 Bundle . Update ( ) ;
77104 }
0 commit comments