@@ -12,8 +12,7 @@ use std::{
12
12
use bytes:: Bytes ;
13
13
use derive_setters:: Setters ;
14
14
use log:: { debug, error, info} ;
15
- use serde_with:: { serde_as, DisplayFromStr } ;
16
- use shell_words:: split;
15
+ use serde_with:: { serde_as, DisplayFromStr , OneOrMany } ;
17
16
18
17
use crate :: {
19
18
backend:: {
@@ -111,7 +110,9 @@ pub struct RepositoryOptions {
111
110
env = "RUSTIC_PASSWORD_COMMAND" ,
112
111
conflicts_with_all = & [ "password" , "password_file" ] ,
113
112
) ) ]
114
- pub password_command : Option < String > ,
113
+ #[ cfg_attr( feature = "merge" , merge( strategy = merge:: vec:: overwrite_empty) ) ]
114
+ #[ serde_as( as = "OneOrMany<_>" ) ]
115
+ pub password_command : Vec < String > ,
115
116
116
117
/// Don't use a cache.
117
118
#[ cfg_attr( feature = "clap" , clap( long, global = true , env = "RUSTIC_NO_CACHE" ) ) ]
@@ -140,7 +141,9 @@ pub struct RepositoryOptions {
140
141
feature = "clap" ,
141
142
clap( long, global = true , conflicts_with = "warm_up" )
142
143
) ]
143
- pub warm_up_command : Option < String > ,
144
+ #[ cfg_attr( feature = "merge" , merge( strategy = merge:: vec:: overwrite_empty) ) ]
145
+ #[ serde_as( as = "OneOrMany<_>" ) ]
146
+ pub warm_up_command : Vec < String > ,
144
147
145
148
/// Duration (e.g. 10m) to wait after warm up
146
149
#[ cfg_attr( feature = "clap" , clap( long, global = true , value_name = "DURATION" ) ) ]
@@ -177,11 +180,10 @@ impl RepositoryOptions {
177
180
) ;
178
181
Ok ( Some ( read_password_from_reader ( & mut file) ?) )
179
182
}
180
- ( _, _, Some ( command) ) => {
181
- let commands = split ( command) . map_err ( RepositoryErrorKind :: FromSplitError ) ?;
182
- debug ! ( "commands: {commands:?}" ) ;
183
- let command = Command :: new ( & commands[ 0 ] )
184
- . args ( & commands[ 1 ..] )
183
+ ( _, _, command) if !command. is_empty ( ) => {
184
+ debug ! ( "commands: {command:?}" ) ;
185
+ let command = Command :: new ( & command[ 0 ] )
186
+ . args ( & command[ 1 ..] )
185
187
. stdout ( Stdio :: piped ( ) )
186
188
. spawn ( ) ?;
187
189
let Ok ( output) = command. wait_with_output ( ) else {
@@ -205,7 +207,7 @@ impl RepositoryOptions {
205
207
}
206
208
} ) )
207
209
}
208
- ( None , None , None ) => Ok ( None ) ,
210
+ ( None , None , _ ) => Ok ( None ) ,
209
211
}
210
212
}
211
213
}
@@ -321,11 +323,11 @@ impl<P> Repository<P, ()> {
321
323
let mut be = backends. repository ( ) ;
322
324
let be_hot = backends. repo_hot ( ) ;
323
325
324
- if let Some ( command ) = & opts. warm_up_command {
325
- if !command . contains ( "%id" ) {
326
+ if ! opts. warm_up_command . is_empty ( ) {
327
+ if opts . warm_up_command . iter ( ) . all ( |c| !c . contains ( "%id" ) ) {
326
328
return Err ( RepositoryErrorKind :: NoIDSpecified . into ( ) ) ;
327
329
}
328
- info ! ( "using warm-up command {command}" ) ;
330
+ info ! ( "using warm-up command {:?}" , opts . warm_up_command ) ;
329
331
}
330
332
331
333
if opts. warm_up {
0 commit comments