Search in sources :

Example 1 with Argument

use of org.kohsuke.args4j.Argument in project buck by facebook.

the class SuggestCommand method runWithoutHelp.

/**
   * Normalizes the sole build target argument and partitions it using a
   * {@link FineGrainedJavaDependencySuggester}.
   */
@Override
public int runWithoutHelp(final CommandRunnerParams params) throws IOException, InterruptedException {
    final Console console = params.getConsole();
    if (arguments.size() != 1) {
        console.printErrorText("Must specify exactly one argument to 'buck suggest'.");
        return 1;
    }
    String targetToBreakDown = Iterables.getOnlyElement(arguments);
    final String fullyQualifiedTarget = Iterables.getOnlyElement(getCommandLineBuildTargetNormalizer(params.getBuckConfig()).normalize(targetToBreakDown));
    JavaBuildGraphProcessor.Processor processor = (graph, javaDepsFinder, executorService) -> {
        BuildTarget buildTarget = params.getBuckConfig().getBuildTargetForFullyQualifiedTarget(fullyQualifiedTarget);
        FineGrainedJavaDependencySuggester suggester = new FineGrainedJavaDependencySuggester(buildTarget, graph, javaDepsFinder, console);
        suggester.suggestRefactoring();
    };
    try {
        JavaBuildGraphProcessor.run(params, this, processor);
    } catch (JavaBuildGraphProcessor.ExitCodeException e) {
        return e.exitCode;
    }
    return 0;
}
Also used : Iterables(com.google.common.collect.Iterables) List(java.util.List) Lists(com.google.common.collect.Lists) Argument(org.kohsuke.args4j.Argument) IOException(java.io.IOException) Console(com.facebook.buck.util.Console) BuildTarget(com.facebook.buck.model.BuildTarget) BuildTarget(com.facebook.buck.model.BuildTarget) Console(com.facebook.buck.util.Console)

Example 2 with Argument

use of org.kohsuke.args4j.Argument in project newts by OpenNMS.

the class MergeSort method createCmdLineParser.

private CmdLineParser createCmdLineParser() {
    return new CmdLineParser(this) {

        @SuppressWarnings("rawtypes")
        @Override
        public void addArgument(final Setter setter, Argument a) {
            Setter newSetter = setter;
            if (setter instanceof MethodSetter) {
                newSetter = new Setter() {

                    @SuppressWarnings("unchecked")
                    @Override
                    public void addValue(Object value) throws CmdLineException {
                        setter.addValue(value);
                    }

                    @Override
                    public Class getType() {
                        return setter.getType();
                    }

                    @Override
                    public boolean isMultiValued() {
                        return false;
                    }

                    @Override
                    public FieldSetter asFieldSetter() {
                        return setter.asFieldSetter();
                    }

                    @Override
                    public AnnotatedElement asAnnotatedElement() {
                        return setter.asAnnotatedElement();
                    }
                };
            }
            super.addArgument(newSetter, a);
        }
    };
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) Argument(org.kohsuke.args4j.Argument) MethodSetter(org.kohsuke.args4j.spi.MethodSetter) FieldSetter(org.kohsuke.args4j.spi.FieldSetter) MethodSetter(org.kohsuke.args4j.spi.MethodSetter) Setter(org.kohsuke.args4j.spi.Setter) FieldSetter(org.kohsuke.args4j.spi.FieldSetter) AnnotatedElement(java.lang.reflect.AnnotatedElement) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 3 with Argument

use of org.kohsuke.args4j.Argument in project gerrit by GerritCodeReview.

the class ReviewCommand method addPatchSetId.

@Argument(index = 0, required = true, multiValued = true, metaVar = "{COMMIT | CHANGE,PATCHSET}", usage = "list of commits or patch sets to review")
void addPatchSetId(String token) {
    try {
        PatchSet ps = psParser.parsePatchSet(token, projectState, branch);
        patchSets.add(ps);
    } catch (UnloggedFailure e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    } catch (StorageException e) {
        throw new IllegalArgumentException("database error", e);
    }
}
Also used : PatchSet(com.google.gerrit.entities.PatchSet) StorageException(com.google.gerrit.exceptions.StorageException) Argument(org.kohsuke.args4j.Argument)

Aggregations

Argument (org.kohsuke.args4j.Argument)3 BuildTarget (com.facebook.buck.model.BuildTarget)1 Console (com.facebook.buck.util.Console)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 PatchSet (com.google.gerrit.entities.PatchSet)1 StorageException (com.google.gerrit.exceptions.StorageException)1 IOException (java.io.IOException)1 AnnotatedElement (java.lang.reflect.AnnotatedElement)1 List (java.util.List)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1 CmdLineParser (org.kohsuke.args4j.CmdLineParser)1 FieldSetter (org.kohsuke.args4j.spi.FieldSetter)1 MethodSetter (org.kohsuke.args4j.spi.MethodSetter)1 Setter (org.kohsuke.args4j.spi.Setter)1