@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()); } }; }
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())); } } }
/** * 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())); } } }
@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;
/** * 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; } }
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()); }
/** * 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)); }
@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;
@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;
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()); }
/** * 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())); } } }
public void onOption( OptionWithUsage optionWithUsage) { out.println("\t" + optionWithUsage.option.name() + ": " + required(optionWithUsage.option) + optionWithUsage.usage); }
/** * 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)); }
@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;
@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;
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; }