All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.bjurr.violations.main.ViolationConfigConverter Maven / Gradle / Ivy

The newest version!
package se.bjurr.violations.main;

import java.util.List;
import java.util.Stack;
import picocli.CommandLine.IParameterConsumer;
import picocli.CommandLine.Model.ArgSpec;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.ParameterException;
import se.bjurr.violations.lib.reports.Parser;

class ViolationConfigConverter implements IParameterConsumer {

  @Override
  public void consumeParameters(
      final Stack args, final ArgSpec argSpec, final CommandSpec commandSpec) {
    if (args.size() < 3) {
      throw new ParameterException(
          commandSpec.commandLine(),
          "Specify violation with parameters:    [NAME]");
    }
    final Parser parser = Parser.valueOf(args.pop());
    final String folder = args.pop();
    final String regexp = args.pop();
    String name = parser.name();
    if (!args.isEmpty()) {
      name = args.pop();
    }
    final List currentValue = (List) argSpec.getValue();
    currentValue.add(new ViolationConfig(parser, folder, regexp, name));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy