@DefaultCommand public void run(@Option(description = "The new directory", defaultValue = "~") Resource<?> r) { if (r != null) { Project currentProject = shell.getCurrentProject(); if (!r.exists()) { if ("~".equals(r.getName()) && currentProject.exists()) { r = currentProject.getProjectRoot(); } else throw new RuntimeException("no such resource: " + r.toString()); } String fullyQualifiedName = r.getFullyQualifiedName(); String userHomePath = OSUtils.getUserHomePath(); if (fullyQualifiedName.startsWith(userHomePath) && "~".equals(r.getFullyQualifiedName().substring(userHomePath.length()))) { r = currentProject.getProjectRoot(); } shell.setCurrentResource(r); } } }
protected Project initializeJavaProject() throws Exception { getShell().setCurrentResource(createTempFolder()); queueInputLines(""); getShell().execute("new-project --named test --topLevelPackage com.test"); Project project = getProject(); tempFolder = project.getProjectRoot(); tempFolders.add(tempFolder); return project; }
@Command(value = "add-locale", help = "Adds another locale in this resource bundle") public void addLocale(@Option(name = "locale", required = true) String locale) { String baseName = "messages"; if (propertiesFileResource != null) { baseName = getBaseBundleName(propertiesFileResource.getName()); } final String baseBundleName = (baseName + "_" + locale + ".properties"); PropertiesFileResource newFileResource = getOrCreate(baseBundleName); shell.setCurrentResource(newFileResource); }
protected Project initializeProject(final PackagingType type) throws Exception { getShell().setCurrentResource(createTempFolder()); queueInputLines(""); getShell().execute("new-project --named test --topLevelPackage com.test --type " + type.toString()); return getProject(); }
shell.setCurrentResource(resource);
@SetupCommand(help = "Configures a bundle for i18n operations") public void setupBundle( final PipeOut out, @Option(name = "bundleName", description = "Bundle Name", defaultValue = "messages") final String bundleName) throws Exception { String fullBundleFile = bundleName.endsWith(".properties") ? bundleName : bundleName + ".properties"; DirectoryResource resourceFolder = project.getFacet(ResourceFacet.class).getResourceFolder(); PropertiesFileResource bundleFile = resourceFolder.getChildOfType(PropertiesFileResource.class, fullBundleFile); if (!bundleFile.exists()) { bundleFile.createNewFile(); } shell.setCurrentResource(bundleFile); out.println("Bundle " + bundleFile + " has been created !"); if (project.hasFacet(FacesFacet.class)) { shell.execute("i18n faces-setup"); } }
@Before public void beforeTest() throws Exception { if (shell == null) { throw new IllegalStateException("Failed to initialize Shell instance for test."); } if (tempFolder == null) { shell.setOutputStream(output); shell.setCurrentResource(createTempFolder()); beanManager.fireEvent(new Startup()); beanManager.fireEvent(new PostStartup()); shell.setVerbose(true); shell.setExceptionHandlingEnabled(false); shell.setAnsiSupported(false); resetInputQueue(); } }
@Before public void beforeTest() throws Exception { shell.setOutputStream(output); shell.setAnsiSupported(false); shell.setCurrentResource(createTempFolder()); beanManager.fireEvent(new Startup()); beanManager.fireEvent(new PostStartup()); shell.setVerbose(true); shell.setExceptionHandlingEnabled(false); resetInputQueue(); }
/** * Adds an entry to the current bundle. * * TODO: Add a completer for current bundle keys * * @param key * @param value */ @Command(value = "put", help = "Adds or modifies an entry in this resource bundle") public void putProperty(@Option(name = "key", required = true, completer = BundleCompleter.class) String key, @Option(name = "value") String value, @Option(name = "locale") String locale) { assertPropertiesInContext(); if (locale == null) { propertiesFileResource.putProperty(key, value); } else { String bundleName = getBaseBundleName(propertiesFileResource.getName()) + "_" + locale + ".properties"; PropertiesFileResource newFileResource = getOrCreate(bundleName); newFileResource.putProperty(key, value); shell.setCurrentResource(newFileResource); } }
shell.setCurrentResource(resource);
shell.setCurrentResource(project.getProjectRoot()); ShellMessages.success(out, "Created project [" + name + "] in new working directory [" + dir.getFullyQualifiedName() + "]");