DefaultOption defaultOptionAnnotation = field.getAnnotation(DefaultOption.class); if (optionAnnotation != null) { OptionType optionType = optionAnnotation.type(); String name; if (!optionAnnotation.title().isEmpty()) { name = optionAnnotation.title(); } else { name = field.getName(); List<String> options = Arrays.asList(optionAnnotation.name()); String description = optionAnnotation.description(); int arity = optionAnnotation.arity(); if (arity < 0 && arity != Integer.MIN_VALUE) throw new IllegalArgumentException(String.format("Invalid arity for option %s", name)); if (optionAnnotation.arity() >= 0) { arity = optionAnnotation.arity(); } else { Class<?> fieldType = field.getType(); boolean hidden = optionAnnotation.hidden(); boolean override = optionAnnotation.override(); boolean sealed = optionAnnotation.sealed(); .createInstance(optionAnnotation.typeConverterProvider());
protected final ChainingClassLoader chainingClassLoader; @Option(name = "--dump-config", description = "Show the effective Graylog configuration and exit") protected boolean dumpConfig = false; @Option(name = "--dump-default-config", description = "Show the default configuration and exit") protected boolean dumpDefaultConfig = false; @Option(name = {"-d", "--debug"}, description = "Run Graylog in debug mode") private boolean debug = false; @Option(name = {"-f", "--configfile"}, description = "Configuration file for Graylog") private String configFile = "/etc/graylog/server/server.conf";
public class JournalShow extends AbstractJournalCommand { @Option(name = {"-s", "--show-segments"}, description = "Show detail information for all segments") private boolean showSegmentDetails = false;
@Command(name = "truncate", description = "Truncates the journal to a given offset") public class JournalTruncate extends AbstractJournalCommand { @Option(name = {"-o", "--offset"}, description = "Truncate journal up to this offset, no remaining offset will be larger than the given offset.") @Required private long offset = Long.MIN_VALUE; public JournalTruncate() { super("truncate-journal"); } @Override protected void runCommand() { try { final long logEndOffset = journal.getLogEndOffset(); if (offset > logEndOffset) { System.err.println("Truncating journal to " + offset + " has no effect as the largest offset in the log is " + (logEndOffset - 1) + "."); } else { journal.truncateTo(offset); } } catch (IllegalArgumentException e) { System.err.println("Illegal offset value " + offset); } } }
@Option(name = {"-l", "--local"}, description = "Run Graylog in local mode. Only interesting for Graylog developers.") private boolean local = false;
@Option( name = CONFIGURATION_FILE_OPTION_NAME, description = "A file specifying configs for Ksql and its underlying Kafka Streams " @Option( name = {USERNAME_OPTION, USERNAME_SHORT_OPTION}, description = private String userName; @Option( name = {PASSWORD_OPTION, PASSWORD_SHORT_OPTION}, description = private String password; @Option( name = STREAMED_QUERY_ROW_LIMIT_OPTION_NAME, description = "An optional maximum number of rows to read from streamed queries") @Option( name = STREAMED_QUERY_TIMEOUT_OPTION_NAME, description = "An optional time limit (in milliseconds) for streamed queries") @Option( name = OUTPUT_FORMAT_OPTION_NAME, description = "The output format to use "
private String propertiesFile; @Option( name = "--queries-file", description = "Path to the query file on the local machine.")
public static abstract class BaseCommand implements Runnable { @Option(name = "--skip-limit-checks", description = "skip system file descriptor/watches checks") public boolean skipLimitChecks; @Option(name = "--enable-log-file", description = "enables logging debug statements to mirror.log") public boolean enableLogFile; @Override public final void run() { if (enableLogFile) { LoggingConfig.enableLogFile(); } if (!skipLimitChecks && !SystemChecks.checkLimits()) { // SystemChecks will have log.error'd some output System.exit(-1); } runIfChecksOkay(); } protected abstract void runIfChecksOkay(); }
@Command(name = "endpoint", description = "starts a SPARQL endpoint powered by Ontop") public class OntopEndpoint extends OntopMappingOntologyRelatedCommand { @Option(type = OptionType.COMMAND, name = {"--port"}, title = "port", description = "port of the SPARQL endpoint") private int port = 8080; @Option(type = OptionType.COMMAND, name = {"--cors-allowed-origins"}, title = "origins", description = "CORS allowed origins") private String corsAllowedOrigins = ","; @Override public void run() { String[] args = { "--ontology=" + this.owlFile, "--mapping=" + this.mappingFile, "--properties=" + this.propertiesFile, "--port=" + this.port, "--cors-allowed-origins=" + this.corsAllowedOrigins }; SpringApplication.run(OntopEndpointApplication.class, args); } }
public static class ComplexDelegate { @Option(name = "-a") public boolean a; }
public static class GitCommand implements Runnable { @Option(type = GLOBAL, name = "-v", description = "Verbose mode") public boolean verbose; public void run() { System.out.println(getClass().getSimpleName()); } }
public static class Delegate { @Option(name = "-a") public String a = "b"; }
public class CommandMain { @Option(type = GLOBAL, name = "-v", description = "Verbose mode") public Boolean verbose = false; }
public static class Delegate { @Option(name = "-a") public String a; }
public class OptionPortBase { @Option(name = "-p", title = "Port", arity = 1) public int port; }