Skip to content

Commit

Permalink
add minimal option mvn option completer
Browse files Browse the repository at this point in the history
  • Loading branch information
jdillon committed Apr 26, 2017
1 parent 186ee09 commit d6f04fc
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ public class MavenAction
implements OpaqueArguments
{
@Inject
public void installCompleters(@Named("maven-phase") final Completer c1,
@Named("maven-plugin") final Completer c2)
public void installCompleters(@Named("maven-option") final Completer c1,
@Named("maven-phase") final Completer c2,
@Named("maven-plugin") final Completer c3)
{
checkNotNull(c1);
checkNotNull(c2);
setCompleters(new AggregateCompleter(c1, c2));
checkNotNull(c3);
setCompleters(new AggregateCompleter(c1, c2, c3));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2009-present the original author or authors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.apache.org/licenses/LICENSE-2.0.html
*
* You may elect to redistribute this code under either of these licenses.
*/

package com.planet57.maven.shell.commands.maven;

import java.util.List;

import javax.inject.Named;
import javax.inject.Singleton;

import org.jline.reader.Candidate;
import org.jline.reader.Completer;
import org.jline.reader.LineReader;
import org.jline.reader.ParsedLine;

import com.planet57.gshell.util.jline.StringsCompleter2;

/**
* Maven option completer.
*
* @since 3.0
*/
@Named("maven-option")
@Singleton
public class MavenOptionCompleter
implements Completer
{
private final StringsCompleter2 delegate = new StringsCompleter2();

public MavenOptionCompleter() {
delegate.addAll(
"-am", "--also-make",
"-B", "--batch-mode",
"-e", "--errors",
"-N", "--non-recursive",
"-X", "--debug"
);
}

@Override
public void complete(final LineReader reader, final ParsedLine line, final List<Candidate> candidates) {
delegate.complete(reader, line, candidates);
}
}

0 comments on commit d6f04fc

Please sign in to comment.