@@ -31,19 +31,28 @@ pub struct CustomCommand {
3131 ///
3232 /// Any status code your command returns which isn't equal zero means fail. But this
3333 /// flag allows to avoid Pipeline early exit, if needed. Error will be ignored.
34- pub ignore_fails : bool ,
34+ ///
35+ /// Default is `false`.
36+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
37+ pub ignore_fails : Option < bool > ,
3538
3639 /// Flag to show output if the command was finished successfully.
3740 ///
3841 /// E.g., if you don't wanna see `cargo build` output when code is built successfully,
3942 /// you can set this flag to `true`.
40- pub show_success_output : bool ,
43+ ///
44+ /// Default is `false`.
45+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
46+ pub show_success_output : Option < bool > ,
4147
4248 /// Flag to show command on screen (during Pipeline execution).
4349 ///
4450 /// Allows to hide constructed command (from `bash_c` and replaced variables) to avoid
4551 /// leaking secrets (keys, tokens, paths to sensitive files, etc.).
46- pub show_bash_c : bool ,
52+ ///
53+ /// Default is `true`.
54+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
55+ pub show_bash_c : Option < bool > ,
4756
4857 /// Flag to run this command only once on repeateable builds.
4958 ///
@@ -193,14 +202,14 @@ impl Execute for CustomCommand {
193202 stdout_strs,
194203 stderr_strs,
195204 command_output. status . success ( ) ,
196- self . show_success_output ,
197- self . show_bash_c ,
205+ self . show_success_output . is_some_and ( |v| v ) ,
206+ self . show_bash_c . is_none_or ( |v| v ) ,
198207 ) ) ;
199208
200209 command_output. status . success ( )
201210 } ;
202211
203- if !self . ignore_fails && !success {
212+ if !self . ignore_fails . is_some_and ( |v| v ) && !success {
204213 return Ok ( ( false , output) ) ;
205214 }
206215 }
@@ -277,7 +286,7 @@ impl Execute for CustomCommand {
277286 res. success ( )
278287 } ;
279288
280- if !self . ignore_fails && !success {
289+ if !self . ignore_fails . is_some_and ( |v| v ) && !success {
281290 return Ok ( ( false , output) ) ;
282291 }
283292 }
@@ -328,7 +337,7 @@ impl CustomCommand {
328337 let remote = match globals. remote_hosts . get ( hostname) {
329338 None => {
330339 output. push ( i18n:: NO_SUCH_REMOTE . to_string ( ) ) ;
331- if !self . ignore_fails {
340+ if !self . ignore_fails . is_some_and ( |v| v ) {
332341 return Ok ( ( false , output) ) ;
333342 }
334343 continue ;
@@ -346,13 +355,13 @@ impl CustomCommand {
346355 out,
347356 String :: new ( ) ,
348357 s,
349- self . show_success_output ,
350- self . show_bash_c ,
358+ self . show_success_output . is_some_and ( |v| v ) ,
359+ self . show_bash_c . is_none_or ( |v| v ) ,
351360 ) ;
352361 composed. pop ( ) ;
353362 output. extend_from_slice ( & composed) ;
354363
355- if !self . ignore_fails && !s {
364+ if !self . ignore_fails . is_some_and ( |v| v ) && !s {
356365 RemoteHost :: close_session ( & mut session, & rt) ?;
357366 return Ok ( ( false , output) ) ;
358367 }
0 commit comments