org.kohsuke.args4j.Option类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(295)

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

Option介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Deprecated
@Override
public CliAuthenticator createCliAuthenticator(final CLICommand command) {
  return new CliAuthenticator() {
    @Option(name="--username",usage="User name to authenticate yourself to Jenkins")
    public String userName;
    @Option(name="--password",usage="Password for authentication. Note that passing a password in arguments is insecure.")
    public String password;
    @Option(name="--password-file",usage="File that contains the password")
    public String passwordFile;
    public Authentication authenticate() throws AuthenticationException, IOException, InterruptedException {
      if (userName==null)
        return command.getTransportAuthentication();    // no authentication parameter. fallback to the transport
      if (passwordFile!=null)
        try {
          password = new FilePath(command.checkChannel(), passwordFile).readToString().trim();
        } catch (IOException e) {
          throw new BadCredentialsException("Failed to read "+passwordFile,e);
        }
      if (password==null)
        password = command.checkChannel().call(new InteractivelyAskForPassword());
      if (password==null)
        throw new BadCredentialsException("No password specified");
      UserDetails d = doAuthenticate(userName, password);
      return new UsernamePasswordAuthenticationToken(d, password, d.getAuthorities());
    }
  };
}

代码示例来源:origin: apache/incubator-pinot

public void printUsage() {
 System.out.println("Usage: " + this.getName());
 for (Field f : this.getClass().getDeclaredFields()) {
  if (f.isAnnotationPresent(Option.class)) {
   Option option = f.getAnnotation(Option.class);
   System.out.println(String
     .format("\t%-25s %-30s: %s (required=%s)", option.name(), option.metaVar(), option.usage(),
       option.required()));
  }
 }
}

代码示例来源:origin: apache/incubator-pinot

/**
 * Helper method to print usage at the command line interface.
 */
private static void printUsage() {
 System.out.println("Usage: DictionaryTORawIndexConverter");
 for (Field field : ColumnarToStarTreeConverter.class.getDeclaredFields()) {
  if (field.isAnnotationPresent(Option.class)) {
   Option option = field.getAnnotation(Option.class);
   System.out
     .println(String.format("\t%-15s: %s (required=%s)", option.name(), option.usage(), option.required()));
  }
 }
}

代码示例来源:origin: jenkinsci/jenkins

@Extension
public class DisconnectNodeCommand extends CLICommand {
  @Argument(metaVar = "NAME", usage = "Slave name, or empty string for master; comma-separated list is supported", required = true, multiValued = true)
  private List<String> nodes;
  @Option(name = "-m", usage = "Record the reason about why you are disconnecting this node")
  public String cause;

代码示例来源:origin: apache/incubator-pinot

public class SegmentDumpTool {
 @Argument
 private String segmentPath;
 @Argument(index = 1, multiValued = true)
 private List<String> columnNames;
 @Option(name = "-dumpStarTree")
 private boolean dumpStarTree;

代码示例来源:origin: jenkinsci/jenkins

/**
 * Quiet down Jenkins - preparation for a restart
 *
 * @author pjanouse
 * @since 2.14
 */
@Extension
public class QuietDownCommand extends CLICommand {

  private static final Logger LOGGER = Logger.getLogger(QuietDownCommand.class.getName());

  @Option(name="-block",usage="Block until the system really quiets down and no builds are running")
  public boolean block = false;

  @Option(name="-timeout",usage="If non-zero, only block up to the specified number of milliseconds")
  public int timeout = 0;

  @Override
  public String getShortDescription() {
    return Messages.QuietDownCommand_ShortDescription();
  }

  @Override
  protected int run() throws Exception {
    Jenkins.getActiveInstance().doQuietDown(block, timeout);
    return 0;
  }
}

代码示例来源:origin: args4j/args4j

public NamedOptionDef(Option o) {
  super(o.usage(),o.metaVar(),o.required(),o.help(),o.hidden(),o.handler(),false);
  this.name = o.name();
  this.aliases = createZeroSizedArrayIfNull(o.aliases());
  this.depends = createZeroSizedArrayIfNull(o.depends());
  this.forbids = createZeroSizedArrayIfNull(o.forbids());
}

代码示例来源:origin: kohsuke/args4j

public int compare(OptionWithUsage o1, OptionWithUsage o2) {
    return o1.option.name().compareTo(o2.option.name());
  }
}

代码示例来源:origin: kohsuke/args4j

/**
 * Programmatically defines an option (instead of reading it from annotations as normal).
 *
 * @param setter the setter for the type
 * @param o the {@code Option}
 * @throws NullPointerException if {@code setter} or {@code o} is {@code null}.
 * @throws IllegalAnnotationError if the option name or one of the aliases is already taken.
 */
public void addOption(Setter setter, Option o) {
  checkNonNull(setter, "Setter");
  checkNonNull(o, "Option");

  checkOptionNotInMap(o.name());
  for (String alias : o.aliases()) {
    checkOptionNotInMap(alias);
  }
  options.add(createOptionHandler(new NamedOptionDef(o), setter));
}

代码示例来源:origin: kohsuke/args4j

private String getUsage(Option o) {
  if(resource==null)
    return o.usage();
  else
    return resource.getProperty(o.usage());
}

代码示例来源:origin: jenkinsci/jenkins

@Extension
public class ConnectNodeCommand extends CLICommand {
  @Argument(metaVar="NAME", usage="Slave name, or empty string for master; comma-separated list is supported", required=true, multiValued=true)
  private List<String> nodes;
  @Option(name="-f", usage="Cancel any currently pending connect operation and retry from scratch")
  public boolean force = false;

代码示例来源:origin: apache/incubator-pinot

@Argument(handler = SubCommandHandler.class, metaVar = "<subCommand>")
@SubCommands({@SubCommand(name = "UpdateSegmentState", impl = UpdateSegmentState.class), @SubCommand(name = "AutoAddInvertedIndex", impl = AutoAddInvertedIndexTool.class), @SubCommand(name = "ValidateTableRetention", impl = ValidateTableRetention.class), @SubCommand(name = "PerfBenchmarkRunner", impl = PerfBenchmarkRunner.class), @SubCommand(name = "QueryRunner", impl = QueryRunner.class)})
Command _subCommand;
@Option(name = "-help", required = false, help = true, aliases = {"-h", "--h", "--help"}, usage = "Print this message.")
boolean _help = false;

代码示例来源:origin: jenkinsci/jenkins

@Extension
public class ListChangesCommand extends RunRangeCommand {
  @Override
  @Option(name="-format",usage="Controls how the output from this command is printed.")
  public Format format = Format.PLAIN;

代码示例来源:origin: kohsuke/args4j

public NamedOptionDef(Option o) {
  super(o.usage(),o.metaVar(),o.required(),o.help(),o.hidden(),o.handler(),false);
  this.name = o.name();
  this.aliases = createZeroSizedArrayIfNull(o.aliases());
  this.depends = createZeroSizedArrayIfNull(o.depends());
  this.forbids = createZeroSizedArrayIfNull(o.forbids());
}

代码示例来源:origin: apache/incubator-pinot

/**
 * Helper method to print usage at the command line interface.
 */
private static void printUsage() {
 System.out.println("Usage: ColumnarToStarTreeConverter");
 for (Field field : ColumnarToStarTreeConverter.class.getDeclaredFields()) {
  if (field.isAnnotationPresent(Option.class)) {
   Option option = field.getAnnotation(Option.class);
   System.out
     .println(String.format("\t%-15s: %s (required=%s)", option.name(), option.usage(), option.required()));
  }
 }
}

代码示例来源:origin: kohsuke/args4j

public void onOption( OptionWithUsage optionWithUsage) {
  out.println("\t" + optionWithUsage.option.name() + ": " + required(optionWithUsage.option)  + optionWithUsage.usage);
}

代码示例来源:origin: args4j/args4j

/**
 * Programmatically defines an option (instead of reading it from annotations as normal).
 *
 * @param setter the setter for the type
 * @param o the {@code Option}
 * @throws NullPointerException if {@code setter} or {@code o} is {@code null}.
 * @throws IllegalAnnotationError if the option name or one of the aliases is already taken.
 */
public void addOption(Setter setter, Option o) {
  checkNonNull(setter, "Setter");
  checkNonNull(o, "Option");

  checkOptionNotInMap(o.name());
  for (String alias : o.aliases()) {
    checkOptionNotInMap(alias);
  }
  options.add(createOptionHandler(new NamedOptionDef(o), setter));
}

代码示例来源:origin: apache/incubator-pinot

@SuppressWarnings("FieldCanBeLocal")
public class ValidateTableRetention extends AbstractBaseCommand implements Command {
 @Option(name = "-zkAddress", required = true, metaVar = "<string>", usage = "Address of the Zookeeper (host:port)")
 private String _zkAddress;
 @Option(name = "-clusterName", required = true, metaVar = "<string>", usage = "Pinot cluster name")
 private String _clusterName;
 @Option(name = "-tableNamePattern", required = false, metaVar = "<string>", usage = "Optional table name pattern to trigger adding inverted index, default: null (match any table name)")
 private String _tableNamePattern = null;
 @Option(name = "-durationInDaysThreshold", required = false, metaVar = "<long>", usage =
   "Optional duration in days threshold to log a warning for table with too large retention time, default: "
     + TableRetentionValidator.DEFAULT_DURATION_IN_DAYS_THRESHOLD)
 private long _durationInDaysThreshold = TableRetentionValidator.DEFAULT_DURATION_IN_DAYS_THRESHOLD;
 @Option(name = "-help", required = false, help = true, aliases = {"-h", "--h", "--help"}, usage = "Print this message.")
 private boolean _help = false;

代码示例来源:origin: jenkinsci/jenkins

@Extension
public class OfflineNodeCommand extends CLICommand {
  @Argument(metaVar = "NAME", usage = "Agent name, or empty string for master", required = true, multiValued = true)
  private List<String> nodes;
  @Option(name = "-m", usage = "Record the reason about why you are disconnecting this node")
  public String cause;

代码示例来源:origin: GoogleCloudPlatform/java-docs-samples

static class Args {
 @Option(name = "--project-id", aliases = "-p", required = true, usage = "Your GCP project ID")
 String projectId;
 @Argument(metaVar = "locationId", required = true, index = 0, usage = "The key location")
 String locationId;
 @Argument(metaVar = "keyRingId", required = true, index = 1, usage = "The key ring id")
 String keyRingId;
 @Argument(metaVar = "cryptoKeyId", required = true, index = 2, usage = "The crypto key id")
 String cryptoKeyId;
 @Argument(metaVar = "inFile", required = true, index = 3, usage = "The source file")
 String inFile;
 @Argument(metaVar = "outFile", required = true, index = 4, usage = "The destination file")
 String outFile;
}

相关文章