com.beust.jcommander.Parameters类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(190)

本文整理了Java中com.beust.jcommander.Parameters类的一些代码示例,展示了Parameters类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parameters类的具体详情如下:
包路径:com.beust.jcommander.Parameters
类名称:Parameters

Parameters介绍

暂无

代码示例

代码示例来源:origin: Meituan-Dianping/walle

@Parameters(commandDescription = "remove channel info for apk")
public class RemoveCommand implements IWalleCommand {

  @Parameter(required = true, description = "file1 file2 file3 ...", converter = FileConverter.class, variableArity = true)
  private List<File> files;

  @Override
  public void parse() {
    removeInfo(new Fun1<File, Boolean>() {
      @Override
      public Boolean apply(final File file) {
        try {
          ChannelWriter.remove(file);
          return true;
        } catch (IOException | SignatureNotFoundException e) {
          e.printStackTrace();
        }
        return false;
      }
    });
  }

  private void removeInfo(final Fun1<File, Boolean> fun) {
    for (File file : files) {
      System.out.println(file.getAbsolutePath() + " : " + fun.apply(file));
    }
  }
}

代码示例来源:origin: Netflix/genie

CommandFactory(
  final List<AgentCommandArguments> agentCommandArguments,
  final ApplicationContext applicationContext
) {
  this.agentCommandArgumentsBeans = agentCommandArguments;
  this.applicationContext = applicationContext;
  agentCommandArguments.forEach(
    commandArgs -> {
      Sets.newHashSet(commandArgs.getClass().getAnnotation(Parameters.class).commandNames()).forEach(
        commandName -> {
          commandMap.put(commandName, commandArgs.getConsumerClass());
        }
      );
    }
  );
}

代码示例来源:origin: ata4/disunity

/**
 *
 * @author Nico Bergemann <barracuda415 at yahoo.de>
 */
@Parameters
public class BundleRoot extends Command {

  @Override
  public void init(JCommander commander, PrintWriter out) {
    super.init(commander, out);

    addSubCommand("list", new BundleList());
    addSubCommand("info", new BundleInfo());
    addSubCommand("pack", new BundlePack());
    addSubCommand("unpack", new BundleUnpack());
  }
}

代码示例来源:origin: com.beust/jcommander

/**
 * @return the description of the command.
 */
public String getCommandDescription(String commandName) {
  JCommander jc = findCommandByAlias(commandName);
  if (jc == null) {
    throw new ParameterException("Asking description for unknown command: " + commandName);
  }
  Object arg = jc.getObjects().get(0);
  Parameters p = arg.getClass().getAnnotation(Parameters.class);
  ResourceBundle bundle = null;
  String result = null;
  if (p != null) {
    result = p.commandDescription();
    String bundleName = p.resourceBundle();
    if (!"".equals(bundleName)) {
      bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
    } else {
      bundle = options.bundle;
    }
    if (bundle != null) {
      String descriptionKey = p.commandDescriptionKey();
      if (!"".equals(descriptionKey)) {
        result = getI18nString(bundle, descriptionKey, p.commandDescription());
      }
    }
  }
  return result;
}

代码示例来源:origin: testwhat/SmaliEx

@Nullable
  public static String getCommandDescription(@Nonnull JCommander jc) {
    Parameters parameters = jc.getObjects().get(0).getClass().getAnnotation(Parameters.class);
    if (parameters == null) {
      return null;
    }
    return parameters.commandDescription();
  }
}

代码示例来源:origin: ata4/disunity

/**
 *
 * @author Nico Bergemann <barracuda415 at yahoo.de>
 */
@Parameters(
  commandDescription = "List object IDs (Unity 5+ only)."
)
public class AssetObjectIDs extends AssetTableCommand {

  @Override
  protected TableModel tableModel(SerializedFile serialized) {
    TableBuilder table = new TableBuilder();
    table.row("Asset Index", "ID in file");

    serialized.metadata().objectIDTable().elements().forEach(objectID -> {
      table.row(objectID.serializedFileIndex(), objectID.identifierInFile());
    });

    return new TableModel("Object IDs", table.get());
  }
}

代码示例来源:origin: ehcache/ehcache3

@Parameters(commandNames = "create", commandDescription = "create a clustered cache manager, and it's caches")
class CreateCacheManager extends AbstractCommand {

 @Parameter(names = {"-c", "--config"}, required = true, description = "configuration file")
 private File config;

 CreateCacheManager(BaseOptions base) {
  super(base);
 }

 @Override
 public int execute() {
  if (getClusterLocationOverride() == null) {
   System.out.println("Creating new cache manager from " + config + (isDryRun() ? " [dry-run]" : ""));
  } else {
   System.out.println("Creating new cache manager from " + config + " at overriding location " + getClusterLocationOverride() + (isDryRun() ? " [dry-run]" : ""));
  }
  return 0;
 }
}

代码示例来源:origin: ata4/disunity

/**
 *
 * @author Nico Bergemann <barracuda415 at yahoo.de>
 */
@Parameters
public class AssetRoot extends Command {

  @Override
  public void init(JCommander commander, PrintWriter out) {
    super.init(commander, out);

    addSubCommand("blocks", new AssetBlocks());
    addSubCommand("externals", new AssetExternalRefs());
    addSubCommand("header", new AssetHeader());
    addSubCommand("objectids", new AssetObjectIDs());
    addSubCommand("objects", new AssetObjects());
    addSubCommand("types", new AssetTypes());
    addSubCommand("unpack", new AssetUnpack());
  }
}

代码示例来源:origin: com.beust/jcommander

public void addCommand(Object object) {
  Parameters p = object.getClass().getAnnotation(Parameters.class);
  if (p != null && p.commandNames().length > 0) {
    for (String commandName : p.commandNames()) {
      addCommand(commandName, object);
    }
  } else {
    throw new ParameterException("Trying to add command " + object.getClass().getName()
        + " without specifying its names in @Parameters");
  }
}

代码示例来源:origin: ata4/disunity

@Parameters(
  commandDescription = "Create bundle from a property file."
  @Parameter(
    names = {"-o", "--output"},
    description = "Asset bundle output file",

代码示例来源:origin: ehcache/ehcache3

@Parameters(commandNames = "list", commandDescription = "list the cache managers and caches within a cluster")
class ListCacheManagers extends AbstractCommand {

 ListCacheManagers(BaseOptions base) {
  super(base);
 }

 @Override
 public int execute() {
  if (getClusterLocationOverride() == null) {
   throw new ParameterException("--cluster option required with the list command");
  } else {
   System.out.println("Listing cache managers at " + getClusterLocationOverride());
  }
  return 0;
 }
}

代码示例来源:origin: ehcache/ehcache3

@Parameters(commandNames = "destroy", commandDescription = "destroy a clustered cache manager, and all of it's caches")
class DestroyCacheManager extends AbstractCommand {

 @Parameter(names = {"-c", "--config"}, required = true, description = "Configuration file to create from")
 private File config;

 @Parameter(names = {"-m", "--match"}, arity = 1, description = "require a matching configuration")
 private boolean requireConfigMatch = true;

 DestroyCacheManager(BaseOptions base) {
  super(base);
 }

 @Override
 public int execute() {
  if (getClusterLocationOverride() == null) {
   System.out.println("Destroying cache manager for config " + config + (isDryRun() ? " [dry-run]" : "") + (requireConfigMatch ? " [matching]" : " [non-matching]"));
  } else {
   System.out.println("Destroying cache manager for config " + config + " at overriding location " + getClusterLocationOverride() + (isDryRun() ? " [dry-run]" : "") + (isDryRun() ? " [matching]" : " [non-matching]"));
  }
  return 0;
 }
}

代码示例来源:origin: ata4/disunity

/**
 *
 * @author Nico Bergemann <barracuda415 at yahoo.de>
 */
@Parameters(
  commandDescription = "Show file header info."
)
public class AssetHeader extends AssetTableCommand {

  @Override
  protected TableModel tableModel(SerializedFile serialized) {
    SerializedFileHeader header = serialized.header();

    TableBuilder table = new TableBuilder();
    table.row("Field", "Value");

    table.row("metadataSize", header.metadataSize());
    table.row("fileSize", header.fileSize());
    table.row("version", header.version());
    table.row("dataOffset", header.dataOffset());

    if (header.version() >= 9) {
      table.row("endianness", header.endianness());
    }

    return new TableModel("Header", table.get());
  }

}

代码示例来源:origin: Netflix/genie

@Parameters(commandNames = CommandNames.INFO, commandDescription = "Print agent and environment information")
  @Getter
  static class InfoCommandArguments implements AgentCommandArguments {
    @Parameter(names = {"--beans"}, description = "Print beans")
    private Boolean includeBeans = true;
    @Parameter(names = {"--env"}, description = "Print environment variables")
    private Boolean includeEnvironment = true;
    @Parameter(names = {"--properties"}, description = "Print properties")
    private boolean includeProperties = true;

    @Override
    public Class<? extends AgentCommand> getConsumerClass() {
      return InfoCommand.class;
    }
  }
}

代码示例来源:origin: ata4/disunity

@Parameters(
  commandDescription = "List external references."

代码示例来源:origin: Meituan-Dianping/walle

@Parameters(commandDescription = "put channel info into apk")
public class PutCommand implements IWalleCommand{
  @Parameter(required = true, description = "inputFile [outputFile]", arity = 2, converter = FileConverter.class)
  private List<File> files;
  @Parameter(names = {"-e", "--extraInfo"}, converter = CommaSeparatedKeyValueConverter.class, description = "Comma-separated list of key=value info, eg: -e time=1,type=android")
  private Map<String, String> extraInfo;
  @Parameter(names = {"-c", "--channel"}, description = "single channel, eg: -c meituan")
  private String channel;

代码示例来源:origin: Netflix/genie

@Parameters(commandNames = CommandNames.HELP, commandDescription = "Print agent usage and help message")
  @Getter
  static class HelpCommandArguments implements AgentCommandArguments {
    @Override
    public Class<? extends AgentCommand> getConsumerClass() {
      return HelpCommand.class;
    }
  }
}

代码示例来源:origin: ehcache/ehcache3

@Parameters(commandNames = "update", commandDescription = "update a clustered cache manager, and it's caches to match a new configuration")
class UpdateCacheManager extends AbstractCommand {

 @Parameter(names = {"-c", "--config"}, required = true, description = "updated configuration file")
 private File config;

 @Parameter(names = {"-d", "--allow-destroy"}, description ="allow destruction of caches")
 private boolean destroy = false;

 @Parameter(names = {"-m", "--allow-mutation"}, description ="allow modification of caches")
 private boolean mutation = false;

 UpdateCacheManager(BaseOptions base) {
  super(base);
 }

 @Override
 public int execute() {
  if (getClusterLocationOverride() == null) {
   System.out.println("Updating cache manager to config " + config + (destroy ? " [destroy allowed]" : "") + (mutation ? " [mutate allowed]" : "") + (isDryRun() ? " [dry-run]" : "") + (isDryRun() ? " [matching]" : " [non-matching]"));
  } else {
   System.out.println("Updating cache manager to config " + config + " at overriding location " + getClusterLocationOverride() + (destroy ? " [destroy allowed]" : "") + (mutation ? " [mutate allowed]" : "") + (isDryRun() ? " [dry-run]" : "") + (isDryRun() ? " [matching]" : " [non-matching]"));
  }
  return 0;
 }
}

代码示例来源:origin: ata4/disunity

@Parameters(
  commandDescription = "List file data blocks."

代码示例来源:origin: google/error-prone

@Parameters(separators = "=")
static class Options {
 @Parameter(names = "-bug_patterns", description = "Path to bugPatterns.txt", required = true)
 private String bugPatterns;
 @Parameter(
   names = "-explanations",
   description = "Path to side-car explanations",
   required = true)
 private String explanations;
 @Parameter(names = "-docs_repository", description = "Path to docs repository", required = true)
 private String docsRepository;
 @Parameter(names = "-examplesDir", description = "Path to examples directory", required = true)
 private String examplesDir;
 @Parameter(
   names = "-target",
   description = "Whether to target the internal or external site",
   converter = TargetEnumConverter.class,
   required = true)
 private Target target;
 @Parameter(
   names = "-use_pygments_highlighting",
   description = "Use pygments for highlighting",
   arity = 1)
 private boolean usePygments = true;
 @Parameter(
   names = "-base_url",
   description = "The base url for links to bugpatterns",
   arity = 1)
 private String baseUrl = null;
}

相关文章