@@ -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,8 @@ 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
+ #[ serde_as( as = "OneOrMany<_>" ) ]
114
+ pub password_command : Vec < String > ,
115
115
116
116
/// Don't use a cache.
117
117
#[ cfg_attr( feature = "clap" , clap( long, global = true , env = "RUSTIC_NO_CACHE" ) ) ]
@@ -140,7 +140,8 @@ pub struct RepositoryOptions {
140
140
feature = "clap" ,
141
141
clap( long, global = true , conflicts_with = "warm_up" )
142
142
) ]
143
- pub warm_up_command : Option < String > ,
143
+ #[ serde_as( as = "OneOrMany<_>" ) ]
144
+ pub warm_up_command : Vec < String > ,
144
145
145
146
/// Duration (e.g. 10m) to wait after warm up
146
147
#[ cfg_attr( feature = "clap" , clap( long, global = true , value_name = "DURATION" ) ) ]
@@ -177,11 +178,10 @@ impl RepositoryOptions {
177
178
) ;
178
179
Ok ( Some ( read_password_from_reader ( & mut file) ?) )
179
180
}
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 ..] )
181
+ ( _, _, command) if !command. is_empty ( ) => {
182
+ debug ! ( "commands: {command:?}" ) ;
183
+ let command = Command :: new ( & command[ 0 ] )
184
+ . args ( & command[ 1 ..] )
185
185
. stdout ( Stdio :: piped ( ) )
186
186
. spawn ( ) ?;
187
187
let Ok ( output) = command. wait_with_output ( ) else {
@@ -205,7 +205,7 @@ impl RepositoryOptions {
205
205
}
206
206
} ) )
207
207
}
208
- ( None , None , None ) => Ok ( None ) ,
208
+ ( None , None , _ ) => Ok ( None ) ,
209
209
}
210
210
}
211
211
}
@@ -321,11 +321,11 @@ impl<P> Repository<P, ()> {
321
321
let mut be = backends. repository ( ) ;
322
322
let be_hot = backends. repo_hot ( ) ;
323
323
324
- if let Some ( command ) = & opts. warm_up_command {
325
- if !command . contains ( "%id" ) {
324
+ if ! opts. warm_up_command . is_empty ( ) {
325
+ if opts . warm_up_command . iter ( ) . all ( |c| !c . contains ( "%id" ) ) {
326
326
return Err ( RepositoryErrorKind :: NoIDSpecified . into ( ) ) ;
327
327
}
328
- info ! ( "using warm-up command {command}" ) ;
328
+ info ! ( "using warm-up command {:?}" , opts . warm_up_command ) ;
329
329
}
330
330
331
331
if opts. warm_up {
0 commit comments