本文整理汇总了Java中net.sourceforge.argparse4j.inf.Namespace.get方法的典型用法代码示例。如果您正苦于以下问题:Java Namespace.get方法的具体用法?Java Namespace.get怎么用?Java Namespace.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sourceforge.argparse4j.inf.Namespace
的用法示例。
在下文中一共展示了Namespace.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<ApplicationConfig> bootstrap, Namespace namespace, ApplicationConfig applicationConfig) throws Exception {
final Path jobSpecsDir = Paths.get(applicationConfig.getJobSpecConfiguration().getDir());
final ArrayList<String> specIds = namespace.get(JOB_SPEC_IDS_ARGNAME);
final Map<JobSpecId, List<String>> allErrors =
specIds.stream()
.map(specId -> getSpecErrors(jobSpecsDir, specId))
.filter(entry -> entry.getValue().size() > 0)
.collect(toMap(e -> e.getKey(), e -> e.getValue()));
if (allErrors.size() > 0) {
allErrors.forEach(this::printErrors);
System.exit(1);
} else System.exit(0);
}
示例2: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<ApplicationConfig> bootstrap, Namespace namespace, ApplicationConfig applicationConfig) throws Exception {
final String specId = namespace.get(SPEC_NAME_ARG);
final Path specsDir = Paths.get(applicationConfig.getJobSpecConfiguration().getDir());
final Path specFile = specsDir.resolve(specId).resolve(SPEC_DIR_SPEC_FILENAME);
if (specFile.toFile().exists()) {
final JobSpec jobSpec = readYAML(specFile, JobSpec.class);
final JobSpecId jobSpecId = new JobSpecId(specId);
final String jobName = new Faker().lorem().sentence(5);
final Map<JobExpectedInputId, JsonNode> generatedInputs = generateInputs(jobSpec);
final APIJobRequest jobRequest =
new APIJobRequest(jobSpecId, jobName, generatedInputs);
System.out.println(toJSON(jobRequest));
System.exit(0);
} else {
System.err.println(specFile + ": No such file");
System.exit(1);
}
}
示例3: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<SamConfiguration> bootstrap, Namespace namespace, SamConfiguration configuration) throws Exception {
final OAuth2Service service = new OAuth2Service(configuration.getOAuthConfiguration());
final Command command = namespace.get("subcommand");
switch (command) {
case create:
create(namespace.getString("subject"), service, configuration);
break;
case verify:
verify(namespace.getString("jwt"), service, configuration);
break;
case sign:
sign(namespace.getString("claims"), service, configuration);
break;
default:
throw new IllegalStateException("Unknown command");
}
}
示例4: handle
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));
ArchiveInfoContext aic = new ArchiveInfoContext(args.get(CLI.ARG_ARCHIVE_PATH), usp);
IFFTraversalTarget t = InventoryPather.traverse(aic.getInventory(), args.getString(ARG_PATH));
if (t.isAFile())
{
throw new CLIException("'path' target must be a folder, not a file.");
}
else
{
IFFContainer c = (IFFContainer) t;
int maxDepth = Integer.MAX_VALUE;
if (args.get(ARG_DEPTH) != null) maxDepth = args.getInt(ARG_DEPTH);
printBreadthFirstFindTree(c, args.get(ARG_PATH), args.get(ARG_PREFIX),
args.get(ARG_SUFFIX),
args.get(ARG_TYPE), maxDepth);
}
}
示例5: main
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String... args) {
WSFRealtimeMain m = new WSFRealtimeMain();
ArgumentParser parser = ArgumentParsers.newArgumentParser("wsf-gtfsrealtime");
parser.description("Produces a GTFS-realtime feed from the Washington State Ferries API");
parser.addArgument("--" + ARG_CONFIG_FILE).type(File.class).help("configuration file path");
Namespace parsedArgs;
try {
parsedArgs = parser.parseArgs(args);
File configFile = parsedArgs.get(ARG_CONFIG_FILE);
m.run(configFile);
} catch (CreationException | ConfigurationException | ProvisionException e) {
_log.error("Error in startup:", e);
System.exit(-1);
} catch (ArgumentParserException ex) {
parser.handleError(ex);
}
}
示例6: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<ApplicationConfig> bootstrap, Namespace namespace, ApplicationConfig applicationConfig) throws Exception {
final UserId login = new UserId(namespace.get(LOGIN_ARG));
final File userFile = new File(applicationConfig.getUsersConfiguration().getFile());
final FilesystemUserDAO dao = new FilesystemUserDAO(userFile);
final boolean userExists = dao.getUserCredentialsById(login).isPresent();
if (!userExists) {
addNewUser(namespace, dao, login);
} else {
System.err.println(format("user '%s' already exists, you can set this user's password with `passwd`.", login));
System.exit(1);
}
}
示例7: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<ApplicationConfig> bootstrap, Namespace namespace, ApplicationConfig applicationConfig) throws Exception {
final UserId login = new UserId(namespace.get(LOGIN_ARG));
final File userFile = new File(applicationConfig.getUsersConfiguration().getFile());
final FilesystemUserDAO dao = new FilesystemUserDAO(userFile);
final boolean userExists = dao.getUserCredentialsById(login).isPresent();
if (userExists) {
System.err.println(format("Changing password for %s.", login));
System.err.print("Enter new Jobson password: ");
System.err.flush();
final String pw = new String(System.console().readPassword());
System.err.print("Retype new Jobson password: ");
System.err.flush();
final String retry = new String(System.console().readPassword());
if (pw.equals(retry)) {
dao.updateUserAuth(login, BASIC_AUTH_NAME, BasicAuthenticator.createAuthField(pw));
} else {
System.err.println("Sorry, passwords do not match");
System.err.println("password unchanged");
System.exit(1);
}
} else {
System.err.println(format("user '%s' does not exist", login));
System.exit(1);
}
}
示例8: run
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
protected void run(Bootstrap<ApplicationConfig> bootstrap, Namespace namespace, ApplicationConfig applicationConfig) throws Exception {
specTemplate = loadResourceFileAsString("spec-template.yml");
final ArrayList<String> specNames = namespace.get(SPEC_NAMES_ARG);
final Path specsDir = Paths.get(applicationConfig.getJobSpecConfiguration().getDir());
if (specsDir.toFile().exists()) {
ensureSpecsDoNotAlreadyExistIn(specsDir, specNames);
createDefaultSpecDirs(specsDir, specNames);
} else {
System.err.println(specsDir + ": No such directory");
System.exit(1);
}
}
示例9: execute
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void execute(final Namespace ns, DockerfileGitHubUtil dockerfileGitHubUtil)
throws IOException, InterruptedException {
loadDockerfileGithubUtil(dockerfileGitHubUtil);
Map<String, String> parentToPath = new HashMap<>();
String img = ns.get(Constants.IMG);
String tag = ns.get(Constants.TAG);
log.info("Updating store...");
this.dockerfileGitHubUtil.updateStore(ns.get(Constants.STORE), img, tag);
log.info("Finding Dockerfiles with the given image...");
PagedSearchIterable<GHContent> contentsWithImage = getGHContents(ns.get("o"), img);
if (contentsWithImage == null) return;
forkRepositoriesFound(parentToPath, contentsWithImage);
GHMyself currentUser = this.dockerfileGitHubUtil.getMyself();
if (currentUser == null) {
throw new IOException("Could not retrieve authenticated user.");
}
PagedIterable<GHRepository> listOfRepos = dockerfileGitHubUtil.getGHRepositories(parentToPath, currentUser);
String message = ns.get("m");
List<IOException> exceptions = new ArrayList<>();
for (GHRepository initialRepo : listOfRepos) {
try {
changeDockerfiles(ns, parentToPath, initialRepo, message);
} catch (IOException e) {
exceptions.add(e);
}
}
if (exceptions.size() > 0) {
log.info("There were {} errors with changing Dockerfiles.", exceptions.size());
throw exceptions.get(0);
}
}
示例10: execute
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void execute(final Namespace ns, final DockerfileGitHubUtil dockerfileGitHubUtil)
throws IOException, InterruptedException {
String branch = ns.get("b");
String img = ns.get(Constants.IMG);
String forceTag = ns.get(Constants.FORCE_TAG);
/* Updates store if a store is specified. */
dockerfileGitHubUtil.updateStore(ns.get(Constants.STORE), img, forceTag);
log.info("Retrieving repository and creating fork...");
GHRepository repo = dockerfileGitHubUtil.getRepo(ns.get(Constants.GIT_REPO));
GHRepository fork = dockerfileGitHubUtil.checkFromParentAndFork(repo);
if (branch == null) {
branch = repo.getDefaultBranch();
}
log.info("Modifying on Github...");
dockerfileGitHubUtil.modifyAllOnGithub(fork, branch, img, forceTag);
String message = ns.get("m");
dockerfileGitHubUtil.createPullReq(repo, branch, fork, message);
/* TODO: A potential problem that requires a design decision:
* 1. Leave forks in authenticated repository.
* Pro: If the pull request has not been merged, it won't create a new pull request.
* Con: Makes a lot of fork repositories on personal repository.
* 2. Delete forks in authenticated repository.
* Pro: No extra repositories on personal repository; authenticated repository stays clean.
* Con: If the pull request not merged yet, it will create a new pull request, making it harder for users
* to read.
*/
// fork.delete();
}
示例11: main
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
public static void main(String[] args) throws ArgumentParserException
{
// Constructing parser and subcommands
ArgumentParser parser = ArgumentParsers.newArgumentParser("bunkr");
String entrypoint = GuiEntryPoint.class.getName();
try
{
entrypoint = new File(GuiEntryPoint.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getName();
}
catch (URISyntaxException ignored) { }
parser.version(
String.format("%s\nversion: %s\ncommit date: %s\ncommit hash: %s",
entrypoint,
Version.versionString,
Version.gitDate,
Version.gitHash));
parser.addArgument("--version").action(Arguments.version());
parser.addArgument("--logging")
.action(Arguments.storeTrue())
.type(Boolean.class)
.setDefault(false)
.help("Enable debug logging. This may be a security issue due to information leakage.");
parser.addArgument("--file")
.type(String.class)
.help("Open a particular archive by file path");
Namespace namespace = parser.parseArgs(args);
if (namespace.getBoolean("logging"))
{
Logging.setEnabled(true);
Logging.info("Logging is now enabled");
}
String[] guiParams = new String[]{namespace.get("file")};
MainApplication.launch(MainApplication.class, guiParams);
}
示例12: handle
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));
ArchiveInfoContext aic = new ArchiveInfoContext(args.get(CLI.ARG_ARCHIVE_PATH), usp);
mkdirs(aic.getInventory(), args.getString(ARG_PATH), args.getBoolean(ARG_RECURSIVE));
MetadataWriter.write(aic, usp);
}
示例13: handle
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));
new ArchiveInfoContext(args.get(CLI.ARG_ARCHIVE_PATH), usp);
System.out.println("Decryption Succeeded");
}
示例14: handle
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));
File archiveFile = args.get(CLI.ARG_ARCHIVE_PATH);
if (archiveFile.exists() && !args.getBoolean(ARG_OVERWRITE))
throw new CLIException("File %s already exists. Pass --overwrite in order to overwrite it.", archiveFile.getAbsolutePath());
ArchiveBuilder.createNewEmptyArchive(archiveFile, new PlaintextDescriptor(), usp);
System.out.println(String.format("Created new archive %s", archiveFile.getAbsolutePath()));
}
示例15: handle
import net.sourceforge.argparse4j.inf.Namespace; //导入方法依赖的package包/类
@Override
public void handle(Namespace args) throws Exception
{
UserSecurityProvider usp = new UserSecurityProvider(makeCLIPasswordProvider(args.get(CLI.ARG_PASSWORD_FILE)));
ArchiveInfoContext aic = new ArchiveInfoContext(args.get(CLI.ARG_ARCHIVE_PATH), usp);
IFFTraversalTarget target = InventoryPather.traverse(aic.getInventory(), args.getString(ARG_PATH));
if (!target.isAFile()) throw new CLIException("'%s' is not a file.", args.getString(ARG_PATH));
FileInventoryItem targetFile = (FileInventoryItem) target;
byte[] digest = calculateHash(aic, targetFile, args.getString(ARG_ALGORITHM), !args.getBoolean(ARG_NO_PROGRESS));
System.out.println(DatatypeConverter.printHexBinary(digest).toLowerCase());
}