}
}
+pub trait OtterArgsSpec {
+ fn to_args(&self) -> Vec<String>;
+}
+
+impl<S> OtterArgsSpec for [S] where for <'s> &'s S: Into<String> {
+ fn to_args(&self) -> Vec<String> {
+ self.iter().map(|s| s.into()).collect()
+ }
+}
+impl<S> OtterArgsSpec for Vec<S> where for <'s> &'s S: Into<String> {
+ fn to_args(&self) -> Vec<String> {
+ self.iter().map(|s| s.into()).collect()
+ }
+}
+
impl DirSubst {
pub fn specs_dir(&self) -> String {
format!("{}/specs" , &self.src)
}
#[throws(AE)]
- pub fn otter<'s,S>(&self, xargs: &'s [S]) -> OtterOutput
- where &'s S: Into<String>
+ pub fn otter(&self, xargs: &dyn OtterArgsSpec) -> OtterOutput
{
self.otter_prctx(&default(), xargs)?
}
#[throws(AE)]
- pub fn otter_prctx<'s,S>(&self, prctx: &PathResolveContext, xargs: &'s [S])
- -> OtterOutput
- where &'s S: Into<String>
+ pub fn otter_prctx(&self, prctx: &PathResolveContext,
+ xargs: &dyn OtterArgsSpec)
+ -> OtterOutput
{
let ds = self;
let exe = ds.subst("@target@/debug/otter")?;
let mut args: Vec<String> = vec![];
args.push("--config" .to_owned()); args.push(prctx.resolve(&CONFIG));
args.push("--spec-dir".to_owned()); args.push(prctx.resolve(&specs) );
- args.extend(xargs.iter().map(|s| s.into()));
+ args.extend(xargs.to_args());
let dbg = format!("running {} {:?}", &exe, &args);
let mut output = NamedTempFile::new_in(
ds.subst("@abstmp@").unwrap()
impl UsualCtx {
#[throws(AE)]
- pub fn otter<S:AsRef<str>>(&mut self, args: &[S]) -> OtterOutput {
+ pub fn otter(&mut self, args: &dyn OtterArgsSpec) -> OtterOutput {
let args: Vec<String> =
["--account", "server:"].iter().cloned().map(Into::into)
- .chain(args.iter().map(|s| s.as_ref().to_owned()))
+ .chain(args.to_args().into_iter())
.collect();
self.su().ds.otter_prctx(&self.prctx, &args)?
}
}
#[throws(AE)]
- pub fn otter_resetting<S:AsRef<str>>(&mut self, args: &[S]) -> OtterOutput {
+ pub fn otter_resetting(&mut self, args: &dyn OtterArgsSpec)
+ -> OtterOutput {
self.has_lib_markers = false;
self.otter(args)?
}
#[throws(Explode)]
- fn some_library_add(&mut self, command: &[String]) -> Vec<String> {
+ fn some_library_add(&mut self, command: &dyn OtterArgsSpec) -> Vec<String> {
let mut session = if ! dbgc!(self.has_lib_markers) {
let add_err = self.otter(command)
.expect_err("library-add succeeded after reset!");
self.connect_player(&self.alice)?
};
- self.otter(&command)
+ self.otter(command)
.expect("library-add failed after place!");
let mut added = vec![];