use of net.sourceforge.argparse4j.inf.ArgumentGroup in project S4T1TM2 by CSUS-CSC-131-Spring2018.
the class YaamServerLauncher method main.
public static void main(String... args) {
// build argument parser
ArgumentParser parser = ArgumentParsers.newFor("TaskManager").addHelp(false).build().defaultHelp(true).description("YAAM WebServer");
// add additional parameters
ArgumentGroup optionalArguments = parser.addArgumentGroup("Optional Arguments");
// allow specifying a configuration file by a filepath
optionalArguments.addArgument("--conf", "--config").dest("configFile").nargs(1).type(File.class).metavar("config.yml").setDefault(new File("yaam-config.yml")).help("Specifies a configuration file by filepath");
// use no external configuration file, use bundled config
optionalArguments.addArgument("--noConfig").dest("noConfig").type(boolean.class).help("Uses default bundled config");
// parse arguments
Namespace namespace = new Namespace(new HashMap<>());
try {
parser.parseArgs(args, namespace.getAttrs());
} catch (ArgumentParserException exception) {
System.err.println("error: " + exception.getMessage());
System.err.println();
parser.printHelp(new PrintWriter(System.err, true));
System.exit(-1);
}
// load YAAM server configuration and settings into memory
YaamConfig config = YaamConfig.load(namespace);
log.info("Loaded configuration");
// construct WebAPI
log.info("Launching web api...");
try {
WebServerAPI apiServer = new WebServerAPI(config);
apiServer.launch();
} catch (Throwable throwable) {
log.fatal("Failed to launch WebServerAPI", throwable);
System.exit(-1);
}
log.info("Web API launched");
// construct WebSocket
log.info("Launching web socket server...");
try {
WebSocketServer webSocketServer = new WebSocketServer(config);
webSocketServer.launch();
} catch (Throwable throwable) {
log.fatal("Failed to launch WebSocketServer", throwable);
System.exit(-1);
}
log.info("Web socket server launched");
log.info("Server running");
}
use of net.sourceforge.argparse4j.inf.ArgumentGroup in project dropwizard by dropwizard.
the class DbDumpCommand method configure.
@Override
public void configure(Subparser subparser) {
super.configure(subparser);
subparser.addArgument("-o", "--output").dest("output").help("Write output to <file> instead of stdout");
final ArgumentGroup tables = subparser.addArgumentGroup("Tables");
tables.addArgument("--tables").action(Arguments.storeTrue()).dest("tables").help("Check for added or removed tables (default)");
tables.addArgument("--ignore-tables").action(Arguments.storeFalse()).dest("tables").help("Ignore tables");
final ArgumentGroup columns = subparser.addArgumentGroup("Columns");
columns.addArgument("--columns").action(Arguments.storeTrue()).dest("columns").help("Check for added, removed, or modified columns (default)");
columns.addArgument("--ignore-columns").action(Arguments.storeFalse()).dest("columns").help("Ignore columns");
final ArgumentGroup views = subparser.addArgumentGroup("Views");
views.addArgument("--views").action(Arguments.storeTrue()).dest("views").help("Check for added, removed, or modified views (default)");
views.addArgument("--ignore-views").action(Arguments.storeFalse()).dest("views").help("Ignore views");
final ArgumentGroup primaryKeys = subparser.addArgumentGroup("Primary Keys");
primaryKeys.addArgument("--primary-keys").action(Arguments.storeTrue()).dest("primary-keys").help("Check for changed primary keys (default)");
primaryKeys.addArgument("--ignore-primary-keys").action(Arguments.storeFalse()).dest("primary-keys").help("Ignore primary keys");
final ArgumentGroup uniqueConstraints = subparser.addArgumentGroup("Unique Constraints");
uniqueConstraints.addArgument("--unique-constraints").action(Arguments.storeTrue()).dest("unique-constraints").help("Check for changed unique constraints (default)");
uniqueConstraints.addArgument("--ignore-unique-constraints").action(Arguments.storeFalse()).dest("unique-constraints").help("Ignore unique constraints");
final ArgumentGroup indexes = subparser.addArgumentGroup("Indexes");
indexes.addArgument("--indexes").action(Arguments.storeTrue()).dest("indexes").help("Check for changed indexes (default)");
indexes.addArgument("--ignore-indexes").action(Arguments.storeFalse()).dest("indexes").help("Ignore indexes");
final ArgumentGroup foreignKeys = subparser.addArgumentGroup("Foreign Keys");
foreignKeys.addArgument("--foreign-keys").action(Arguments.storeTrue()).dest("foreign-keys").help("Check for changed foreign keys (default)");
foreignKeys.addArgument("--ignore-foreign-keys").action(Arguments.storeFalse()).dest("foreign-keys").help("Ignore foreign keys");
final ArgumentGroup sequences = subparser.addArgumentGroup("Sequences");
sequences.addArgument("--sequences").action(Arguments.storeTrue()).dest("sequences").help("Check for changed sequences (default)");
sequences.addArgument("--ignore-sequences").action(Arguments.storeFalse()).dest("sequences").help("Ignore sequences");
final ArgumentGroup data = subparser.addArgumentGroup("Data");
data.addArgument("--data").action(Arguments.storeTrue()).dest("data").help("Check for changed data").setDefault(Boolean.FALSE);
data.addArgument("--ignore-data").action(Arguments.storeFalse()).dest("data").help("Ignore data (default)").setDefault(Boolean.FALSE);
}
use of net.sourceforge.argparse4j.inf.ArgumentGroup in project neo4j by neo4j.
the class CliArgHelper method setupParser.
private static ArgumentParser setupParser(ParameterMap parameterMap) {
ArgumentParser parser = ArgumentParsers.newFor("cypher-shell").build().defaultHelp(true).description(format("A command line shell where you can execute Cypher against an instance of Neo4j. " + "By default the shell is interactive but you can use it for scripting by passing cypher " + "directly on the command line or by piping a file with cypher statements (requires Powershell on Windows)." + "%n%n" + "example of piping a file:%n" + " cat some-cypher.txt | cypher-shell"));
ArgumentGroup connGroup = parser.addArgumentGroup("connection arguments");
connGroup.addArgument("-a", "--address").help("address and port to connect to").setDefault(String.format("%s://%s:%d", CliArgs.DEFAULT_SCHEME, CliArgs.DEFAULT_HOST, CliArgs.DEFAULT_PORT));
connGroup.addArgument("-u", "--username").setDefault("").help("username to connect as. Can also be specified using environment variable " + ConnectionConfig.USERNAME_ENV_VAR);
connGroup.addArgument("-p", "--password").setDefault("").help("password to connect with. Can also be specified using environment variable " + ConnectionConfig.PASSWORD_ENV_VAR);
connGroup.addArgument("--encryption").help("whether the connection to Neo4j should be encrypted. This must be consistent with Neo4j's " + "configuration. If choosing '" + Encryption.DEFAULT.name().toLowerCase() + "' the encryption setting is deduced from the specified address. " + "For example the 'neo4j+ssc' protocol would use encryption.").choices(new CollectionArgumentChoice<>(Encryption.TRUE.name().toLowerCase(), Encryption.FALSE.name().toLowerCase(), Encryption.DEFAULT.name().toLowerCase())).setDefault(Encryption.DEFAULT.name().toLowerCase());
connGroup.addArgument("-d", "--database").help("database to connect to. Can also be specified using environment variable " + ConnectionConfig.DATABASE_ENV_VAR).setDefault("");
MutuallyExclusiveGroup failGroup = parser.addMutuallyExclusiveGroup();
failGroup.addArgument("--fail-fast").help("exit and report failure on first error when reading from file (this is the default behavior)").dest("fail-behavior").setConst(FAIL_FAST).action(new StoreConstArgumentAction());
failGroup.addArgument("--fail-at-end").help("exit and report failures at end of input when reading from file").dest("fail-behavior").setConst(FAIL_AT_END).action(new StoreConstArgumentAction());
parser.setDefault("fail-behavior", FAIL_FAST);
parser.addArgument("--format").help("desired output format, verbose displays results in tabular format and prints statistics, " + "plain displays data with minimal formatting").choices(new CollectionArgumentChoice<>(Format.AUTO.name().toLowerCase(), Format.VERBOSE.name().toLowerCase(), Format.PLAIN.name().toLowerCase())).setDefault(Format.AUTO.name().toLowerCase());
parser.addArgument("-P", "--param").help("Add a parameter to this session. Example: `-P \"number => 3\"`. This argument can be specified multiple times.").action(new AddParamArgumentAction(parameterMap));
parser.addArgument("--debug").help("print additional debug information").action(new StoreTrueArgumentAction());
parser.addArgument("--non-interactive").help("force non-interactive mode, only useful if auto-detection fails (like on Windows)").dest("force-non-interactive").action(new StoreTrueArgumentAction());
parser.addArgument("--sample-rows").help("number of rows sampled to compute table widths (only for format=VERBOSE)").type(new PositiveIntegerType()).dest("sample-rows").setDefault(CliArgs.DEFAULT_NUM_SAMPLE_ROWS);
parser.addArgument("--wrap").help("wrap table column values if column is too narrow (only for format=VERBOSE)").type(new BooleanArgumentType()).setDefault(true);
parser.addArgument("-v", "--version").help("print version of cypher-shell and exit").action(new StoreTrueArgumentAction());
parser.addArgument("--driver-version").help("print version of the Neo4j Driver used and exit").dest("driver-version").action(new StoreTrueArgumentAction());
parser.addArgument("cypher").nargs("?").help("an optional string of cypher to execute and then exit");
parser.addArgument("-f", "--file").help("Pass a file with cypher statements to be executed. After the statements have been executed cypher-shell will be shutdown");
return parser;
}
use of net.sourceforge.argparse4j.inf.ArgumentGroup in project claw-compiler by C2SM-RCM.
the class CLIOptions method parseArguments.
public static CLIOptions parseArguments(String[] args) throws Exception {
ArgumentParser parser = ArgumentParsers.newFor("claw-cx2t").build().description("The CLAW Compiler is a " + "source-to-source translator working on the XcodeML intermediate representation");
Namespace parsedArgs = null;
try {
parser.addArgument("input-xast-file").nargs("?").help("Input XCodeML file");
MutuallyExclusiveGroup qOpts = parser.addMutuallyExclusiveGroup("Query options");
qOpts.addArgument("--print-opts").action(Arguments.storeTrue()).help("Print processed cmdline options");
qOpts.addArgument("--version").action(Arguments.storeTrue()).help("Print version");
qOpts.addArgument("-tl", "--target-list").action(Arguments.storeTrue()).help("List all targets supported by code transformation");
qOpts.addArgument("-dl", "--directive-list").action(Arguments.storeTrue()).help("List all directive languages supported by code generation");
qOpts.addArgument("-sc", "--show-config").action(Arguments.storeTrue()).help("Display the current configuration");
ArgumentGroup cOpts = parser.addArgumentGroup("Translator options");
cOpts.addArgument("-l", "--suppress-pp-line-directives").action(Arguments.storeTrue()).help("Suppress line directive in decompiled code");
cOpts.addArgument("-cp", "--config-path").help("Path to configuration directory");
cOpts.addArgument("-c", "--config").help("Path to translator configuration file");
cOpts.addArgument("-t", "--target").help("Code transformation target platform");
cOpts.addArgument("-dir", "--directive").help("Target directive language to be used in code generation");
cOpts.addArgument("-d", "--debug").action(Arguments.storeTrue()).help("Enable output debug message");
cOpts.addArgument("-f", "--out-ftn-file").help("Output file for decompiled FORTRAN source");
cOpts.addArgument("-o", "--out-xast-file").help("Output file for transformed XcodeML");
cOpts.addArgument("-r", "--report").help("Output file for the transformation report");
cOpts.addArgument("-M", "--mod-include-dir").nargs("*").action(Arguments.append()).help("Search directory for .xmod files");
cOpts.addArgument("-w", "--max-fortran-line-length").type(Integer.class).help("Number of character per line in decompiled code");
cOpts.addArgument("-fp", "--force-pure").action(Arguments.storeTrue()).help("Exit the translator if a PURE subroutine/function has to be transformed");
cOpts.addArgument("-m", "--model-config").help("Model configuration file for SCA transformation");
cOpts.addArgument("-x", "--override-cfg-key").nargs("*").action(Arguments.append()).help("Override configuration option. Has higher priority than base and user configuration");
cOpts.addArgument("-ap", "--add-paren").action(Arguments.storeTrue()).help("Force backend to add parentheses around binary mathematical operations");
cOpts.addArgument("-td", "--trans-path-dir").nargs("*").action(Arguments.append()).help("Search directory for external transformation set");
parsedArgs = parser.parseArgs(args);
} catch (HelpScreenException hse) {
return null;
} catch (ArgumentParserException ape) {
parser.handleError(ape);
throw ape;
}
CLIOptions opts = new CLIOptions(parsedArgs);
return opts;
}
use of net.sourceforge.argparse4j.inf.ArgumentGroup in project claw-compiler by C2SM-RCM.
the class Options method parseCmdlineArguments.
public static Options parseCmdlineArguments(String[] args, Path workingDir) throws Exception {
ArgumentParser parser = ArgumentParsers.newFor("clawfc").build().description("The CLAW Compiler is a " + "source-to-source translator working on the XcodeML intermediate representation");
Namespace parsedArgs = null;
try {
parser.addArgument("fortran-file").nargs("*").action(Arguments.append()).help("Input file");
MutuallyExclusiveGroup qOpts = parser.addMutuallyExclusiveGroup("Query options");
qOpts.addArgument("--list-targets", "--target-list").action(Arguments.storeTrue()).help("List available types of accelerator hardware");
qOpts.addArgument("--list-directives", "--directive-list").action(Arguments.storeTrue()).help("List supported accelerator directive languages");
qOpts.addArgument("--show-config").action(Arguments.storeTrue()).help("List the current configuration information. If used with --config, list the information" + " from the specific configuration");
qOpts.addArgument("--version").action(Arguments.storeTrue()).help("Print version");
qOpts.addArgument("--print-install-cfg", "--show-env").action(Arguments.storeTrue()).help("Print install configuration");
qOpts.addArgument("--print-opts").action(Arguments.storeTrue()).help("Print processed cmdline options");
qOpts.addArgument("--print-claw-files").action(Arguments.storeTrue()).help("Print input files which use CLAW directives");
MutuallyExclusiveGroup outOpts = parser.addMutuallyExclusiveGroup("Compiler output options");
outOpts.addArgument("-o", "--output-file").help("Output file for the transformed FORTRAN code. If not given, code is printed to stdout");
outOpts.addArgument("-O", "--output-dir").help("Output directory for transformed FORTRAN files");
ArgumentGroup cOpts = parser.addArgumentGroup("Compiler options");
cOpts.addArgument("-I", "--pp-include-dir").nargs("*").action(Arguments.append()).help("Add the directory to the search path for include files reference in preprocessor directives and FORTRAN include statements");
cOpts.addArgument("-PO", "--pp-output-dir").help("Output directory for preprocessed FORTRAN source files");
cOpts.addArgument("-D", "--add-macro").nargs("*").action(Arguments.append()).help("Predefine macro");
cOpts.addArgument("-SI", "--src-include-dir").nargs("*").action(Arguments.append()).help("Add directory to the search path for the source of referenced Fortran modules");
cOpts.addArgument("-M", "-MI", "--mod-include-dir").nargs("*").action(Arguments.append()).help("Add directory to the search path for .xmod files.");
cOpts.addArgument("-MO", "--mod-output-dir").help("Output directory for .xmod files.");
cOpts.addArgument("-MD", "--make-dep-file").nargs("?").setConst("").help("Generate GNU Make dependency file. Default value is <output file>.d");
cOpts.addArgument("-J").nargs("*").action(Arguments.append()).help("DEPRECATED Add directory to the search path for the source of referenced Fortran modules and .xmod files." + " First given is also output directory for generated .xmod files");
cOpts.addArgument("-BI", "--buildinfo-include-dir").nargs("*").action(Arguments.append()).help("Include directory for BuildInfo files");
cOpts.addArgument("-BO", "--buildinfo-output-dir").help("Output directory for BuildInfo files");
cOpts.addArgument("-XO", "--xast-output-dir").help("Output directory for modules transformed into XCodeML-AST");
cOpts.addArgument("-TXO", "--txast-output-dir").help("Output directory for translated XCodeML-AST program units");
cOpts.addArgument("-TRO", "--trans-report-output-dir").help("Output directory for transformation reports");
cOpts.addArgument("-TSO", "--tsrc-output-dir").help("Output directory for decompiled source program units");
cOpts.addArgument("-t", "--target").help("Type of target accelerator hardware");
cOpts.addArgument("-d", "--directive").help("Specify accelerator directive language to be used for code generation");
cOpts.addArgument("--config").help("Specify a different configuration for the translator");
cOpts.addArgument("-m", "--model-config").help("Specific model configuration for SCA");
cOpts.addArgument("-c", "--keep-comment").action(Arguments.storeTrue()).help("Keep comments in the transformed file");
cOpts.addArgument("-v", "--verbose").action(Arguments.storeTrue()).help("Print processing status");
cOpts.addArgument("--no-dep").action(Arguments.storeTrue()).help("Don't generate .mod or .xmod file for dependencies");
cOpts.addArgument("--no-module-cache").action(Arguments.storeTrue()).help("Deactivate module cache in the front-end");
cOpts.addArgument("-f", "--force").action(Arguments.storeTrue()).help("Force the translation of modules without directives");
cOpts.addArgument("--force-pure").action(Arguments.storeTrue()).help("Force compiler to exit when transformation applied to PURE subroutine/function");
cOpts.addArgument("--add-paren").action(Arguments.storeTrue()).help("Add parenthesis to binary operation in generated code");
cOpts.addArgument("--debug").action(Arguments.storeTrue()).help("Display transformation debug information");
cOpts.addArgument("--int-dir").help("Path to intermediate files directory (all existing contents will be removed)");
cOpts.addArgument("--keep-int-files").action(Arguments.storeTrue()).help("Keep intermediate files");
cOpts.addArgument("--debug-ffront").action(Arguments.storeTrue()).help("Drive OMNI Fortran front-end in debug mode");
cOpts.addArgument("--skip-pp").action(Arguments.storeTrue()).help("Do not apply preprocessing to input and include files");
MutuallyExclusiveGroup sOpts = parser.addMutuallyExclusiveGroup("Compiler debug options");
sOpts.addArgument("--stop-pp").action(Arguments.storeTrue()).help("Stop after preprocessing");
sOpts.addArgument("--stop-depscan").action(Arguments.storeTrue()).help("Stop after dependencies scan");
sOpts.addArgument("--stop-xmod-gen").action(Arguments.storeTrue()).help("Stop after Xmod generation");
sOpts.addArgument("--stop-xast-gen").action(Arguments.storeTrue()).help("Stop after XML-AST generation");
sOpts.addArgument("--stop-trans").action(Arguments.storeTrue()).help("Stop after translator");
sOpts.addArgument("--stop-dec").action(Arguments.storeTrue()).help("Stop after decompilation");
cOpts.addArgument("--gen-buildinfo-files").action(Arguments.storeTrue()).help("Generate build information files for input and then stop");
cOpts.addArgument("--gen-mod-files").nargs("*").action(Arguments.append()).setConst("").help("Generate xmod files for input and then stop. List of target module names can be optionally supplied.");
cOpts.addArgument("-x", "--override-cfg-key").nargs("*").action(Arguments.append()).help("Override a configuration key:value pair from the command line. Higher " + "priority over base configuration and user configuration");
cOpts.addArgument("--dump-cx2t-args").action(Arguments.storeTrue()).help("Print arguments passed to CX2T");
MutuallyExclusiveGroup mpOpts = parser.addMutuallyExclusiveGroup("Compiler multiprocessing options");
mpOpts.addArgument("-mp", "--max-num-mp-jobs").type(Integer.class).help("Maximum number of multiprocessing jobs");
mpOpts.addArgument("--disable-mp").action(Arguments.storeTrue()).help("Disable multiprocessing");
cOpts.addArgument("-mj", "--sync-with-gmake").action(Arguments.storeTrue()).help("Synchronize number of threads with GNU Make job server");
ArgumentGroup dcOpts = parser.addArgumentGroup("Decompiler options");
dcOpts.addArgument("--max-fortran-line-length", "-w").type(Integer.class).setDefault(Integer.valueOf(80)).help("Set the number of columns for the output FORTRAN file (default: 80)");
dcOpts.addArgument("-l", "--add-pp-line-directives").action(Arguments.storeTrue()).help("Add preprocessor line directives in the output FORTRAN file");
cOpts.addArgument("-E", "--only-preprocess").action(Arguments.storeTrue()).help("Only apply preprocessor to input files");
ArgumentGroup pOpts = parser.addArgumentGroup("Process options");
pOpts.addArgument("--add-pp-opts", "--Wp").nargs("*").action(Arguments.append()).help("Add preprocessor option");
pOpts.addArgument("--add-ffront-opts", "--Wf").nargs("*").action(Arguments.append()).help("Add frontend option");
pOpts.addArgument("--add-trans-opts", "--Wx").nargs("*").action(Arguments.append()).help("Add Xcode translator option");
ArgumentGroup fcOpts = parser.addArgumentGroup("Fortran compiler options");
final List<String> FC_COMPILER_VENDORS = Arrays.stream(FortranCompilerVendor.values()).map(val -> val.toString().toLowerCase()).collect(Collectors.toList());
fcOpts.addArgument("--fc-vendor").choices(FC_COMPILER_VENDORS).help("Fortran compiler type");
fcOpts.addArgument("--fc-cmd").help("Fortran compiler cmd");
cOpts.addArgument("-td", "--trans-path-dir").nargs("*").action(Arguments.append()).help("Search directory for external transformation set");
parser.addArgument("--ffront-debug-dir").help("Output directory to collect OMNI failures for easier debugging");
parsedArgs = parser.parseArgs(args);
} catch (HelpScreenException hse) {
return null;
} catch (ArgumentParserException ape) {
parser.handleError(ape);
throw ape;
}
Options opts = new Options(parsedArgs, workingDir);
return opts;
}
Aggregations