SubstituteCommand.java
package org.docascode.api;
import org.docascode.api.core.errors.DocAsCodeException;
import org.docascode.api.core.DocAsCodeRepository;
import org.docascode.api.core.Substitute;
import org.docascode.api.core.office.Properties;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class SubstituteCommand extends DocAsCodeCommand<Map<String,String> > {
private File file = null;
private List<String> strings = new ArrayList<>();
protected SubstituteCommand(DocAsCodeRepository repo) {
super(repo);
}
public SubstituteCommand setFile(File file){
this.file = file;
return this;
}
public SubstituteCommand add(String string){
this.strings.add(string);
return this;
}
@Override
public Map<String, String> call() throws DocAsCodeException {
Map<String,String> dict = Properties.list(file);
return Substitute.substitute(strings,dict);
}
}