DocAsCodeCtrl.java
package org.docascode;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.docascode.git.ConfigCtrl;
import org.docascode.utils.DocAsCodeException;
import org.docascode.utils.Utils;
import java.util.ArrayList;
import java.util.List;
public class DocAsCodeCtrl {
static class ManifestVersionProvider implements picocli.CommandLine.IVersionProvider {
public String[] getVersion() {
List<String> versionInfos = new ArrayList<String>();
DefaultArtifactVersion docascodeVersion = new DefaultArtifactVersion(Utils.getDocAsCodeVersion());
versionInfos.add("DocAsCode version " + Utils.getDocAsCodeVersion());
try {
DefaultArtifactVersion repoVersion = new DefaultArtifactVersion(Utils.getRepository().getVersion());
if (docascodeVersion.compareTo(repoVersion) > 0) {
versionInfos.add("Your repository was initialized with DocAsCode version " + repoVersion.toString() + ". You should upgrade your repository. Try 'docascode init'.");
} else {
if (docascodeVersion.compareTo(repoVersion) < 0) {
versionInfos.add("Your repository was initialized with DocAsCode version " + repoVersion.toString() + ". You should update your docascode installation.");
} else {
versionInfos.add("Your repository is up-to-date w.r.t. your docascode installation");
}
}
} catch (DocAsCodeException e) {
} finally {
String[] versions = new String[versionInfos.size()];
versions = versionInfos.toArray(versions);
return versions;
}
}
}
}