use of jline.console.ConsoleReader in project apex-core by apache.
the class ApexCliTest method testAppFromOnlyConfigPackage.
@Test
public void testAppFromOnlyConfigPackage() throws Exception {
ApexCli.LaunchCommandLineInfo commandLineInfo = ApexCli.getLaunchCommandLineInfo(new String[] { "-conf", configFile.getAbsolutePath(), appFile.getAbsolutePath(), "-useConfigApps", "exclusive" });
ApexCli apexCli = new ApexCli();
apexCli.init();
Assert.assertEquals("configApps", "exclusive", commandLineInfo.useConfigApps);
apexCli.getLaunchAppPackageArgs(ap, cp, commandLineInfo, new ConsoleReader());
Assert.assertEquals(ap.getApplications().size(), 1);
Assert.assertEquals(ap.getApplications().get(0).displayName, "testApp");
Assert.assertEquals(ap.getApplications().get(0).type, "json");
}
use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.
the class Cat method runInternal.
@Override
public void runInternal(GeogigCLI cli) throws IOException {
checkParameter(paths.size() < 2, "Only one refspec allowed");
checkParameter(!paths.isEmpty(), "A refspec must be specified");
ConsoleReader console = cli.getConsole();
GeoGIG geogig = cli.getGeogig();
String path = paths.get(0);
Optional<RevObject> obj = geogig.command(RevObjectParse.class).setRefSpec(path).call();
checkParameter(obj.isPresent(), "refspec did not resolve to any object.");
if (binary) {
ObjectSerializingFactory factory = DataStreamSerializationFactoryV1.INSTANCE;
ObjectWriter<RevObject> writer = factory.createObjectWriter(obj.get().getType());
writer.write(obj.get(), System.out);
} else {
CharSequence s = geogig.command(CatObject.class).setObject(Suppliers.ofInstance(obj.get())).call();
console.println(s);
}
}
use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.
the class ShowRef method runInternal.
@Override
public void runInternal(GeogigCLI cli) throws IOException {
ConsoleReader console = cli.getConsole();
GeoGIG geogig = cli.getGeogig();
ForEachRef op = geogig.command(ForEachRef.class);
Predicate<Ref> filter = new Predicate<Ref>() {
@Override
public boolean apply(Ref ref) {
String name = ref.getName();
if (!name.startsWith(Ref.REFS_PREFIX)) {
return false;
}
boolean match = patterns.isEmpty() ? true : false;
for (String pattern : patterns) {
if (Strings.isNullOrEmpty(pattern)) {
match = true;
} else if (name.endsWith("/" + pattern)) {
match = true;
break;
}
}
return match;
}
};
op.setFilter(filter);
ImmutableSet<Ref> refs = op.call();
for (Ref ref : refs) {
console.println(ref.getObjectId() + " " + ref.getName());
}
}
use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.
the class Add method runInternal.
/**
* Executes the add command using the provided options.
*
* @param cli
* @see org.locationtech.geogig.cli.AbstractCommand#runInternal(org.locationtech.geogig.cli.GeogigCLI)
*/
@Override
public void runInternal(GeogigCLI cli) throws IOException {
final GeoGIG geogig = cli.getGeogig();
final ConsoleReader console = cli.getConsole();
String pathFilter = null;
if (patterns.size() == 1) {
pathFilter = patterns.get(0);
} else if (patterns.size() > 1) {
throw new InvalidParameterException("Only a single path is supported so far");
}
List<Conflict> conflicts = geogig.command(ConflictsReadOp.class).call();
console.print("Counting unstaged elements...");
console.flush();
DiffObjectCount unstaged = geogig.getRepository().workingTree().countUnstaged(pathFilter);
if (0 == unstaged.count() && conflicts.isEmpty()) {
console.println();
console.println("No unstaged elements, exiting.");
return;
} else {
console.println(String.valueOf(unstaged.count()));
}
console.println("Staging changes...");
AddOp op = geogig.command(AddOp.class);
if (patterns.size() == 1) {
op.addPattern(patterns.get(0));
}
WorkingTree workTree = op.setUpdateOnly(updateOnly).setProgressListener(cli.getProgressListener()).call();
DiffObjectCount staged = geogig.getRepository().index().countStaged(null);
unstaged = workTree.countUnstaged(null);
console.println(staged.featureCount() + " features and " + staged.treeCount() + " trees staged for commit");
console.println(unstaged.featureCount() + " features and " + unstaged.treeCount() + " trees not staged for commit");
}
use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.
the class MergeBase method runInternal.
@Override
public void runInternal(GeogigCLI cli) throws IOException {
checkParameter(commits.size() == 2, "Two commit references must be provided");
ConsoleReader console = cli.getConsole();
GeoGIG geogig = cli.getGeogig();
Optional<RevObject> left = geogig.command(RevObjectParse.class).setRefSpec(commits.get(0)).call();
checkParameter(left.isPresent(), commits.get(0) + " does not resolve to any object.");
checkParameter(left.get() instanceof RevCommit, commits.get(0) + " does not resolve to a commit");
Optional<RevObject> right = geogig.command(RevObjectParse.class).setRefSpec(commits.get(1)).call();
checkParameter(right.isPresent(), commits.get(1) + " does not resolve to any object.");
checkParameter(right.get() instanceof RevCommit, commits.get(1) + " does not resolve to a commit");
Optional<ObjectId> ancestor = geogig.command(FindCommonAncestor.class).setLeft((RevCommit) left.get()).setRight((RevCommit) right.get()).call();
checkParameter(ancestor.isPresent(), "No common ancestor was found.");
console.print(ancestor.get().toString());
}
Aggregations