/** * Shellifies a command name * * @param name * @return */ public static String shellifyCommandName(String name) { return Commands.shellifyCommandName(name); }
/** * Shellifies an option name * * @param name * @return */ public static String shellifyOptionName(String name) { return shellifyName(name); }
/** * Shellifies an option name * * @param name * @return */ public static String shellifyOptionName(String name) { return Commands.shellifyOptionName(name); }
/** * Returns the main commands from this {@link Iterable} (that is, the ones that are enabled and not a * {@link UIWizardStep} instance) */ public static Iterable<UICommand> getEnabledCommands(Iterable<UICommand> commands, UIContext context) { List<UICommand> result = new LinkedList<>(); for (UICommand uiCommand : commands) { try { if (isEnabled(uiCommand, context)) { result.add(uiCommand); } } catch (Exception e) { log.log(Level.SEVERE, "Could not call method " + UICommand.class.getName() + "`isEnabled(UIContext ctx)` of type [" + uiCommand + "] with Metadata [" + getMetadata(uiCommand, context) + "].", e); } } return result; }
/** * Shellifies an option name using the provided style * * @param name * @param style * @return */ public static String shellifyOptionNameDashed(String name) { return Commands.shellifyOptionNameDashed(name); }
private void configureStack(InputComponentFactory factory, final UIContext context) { NoStackFacet defaultStack = SimpleContainer.getServices(getClass().getClassLoader(), NoStackFacet.class) .get(); Imported<StackFacet> stacks = SimpleContainer.getServices(getClass().getClassLoader(), StackFacet.class); final List<StackFacet> list = Lists.toList(stacks); Collections.sort(list, new StackFacetComparator()); stack = factory.createSelectOne("stack", StackFacet.class) .setLabel("Stack") .setDescription("The technology stack to be used in this project") .setValueChoices(() -> list.stream() .filter((stackFacet) -> (type.hasValue() || type.hasDefaultValue()) && type.getValue().supports(stackFacet.getStack())) .collect(Collectors.toSet())) // Enable stack field only if any stack is available .setEnabled(() -> Sets.toSet(stack.getValueChoices()).size() > 1) .setDefaultValue(defaultStack) .setItemLabelConverter((facet) -> context.getProvider().isGUI() ? facet.getStack().getName() : Commands.shellifyOptionValue(facet.getStack().getName())); }
@Override public void initializeUI(UIBuilder builder) throws Exception { springBootVersion.setValueChoices(Arrays.asList(SPRING_BOOT_VERSIONS)); springBootVersion.setDefaultValue(SPRING_BOOT_DEFAULT_VERSION); try { choices = initDependencies(); } catch (Exception e) { throw new IllegalStateException("Error loading dependencies from spring-boot-application.yaml due: " + e.getMessage(), e); } dependencies.setValueChoices(choices); if (builder.getUIContext().getProvider().isGUI()) { dependencies.setItemLabelConverter(SpringBootDependencyDTO::getGroupAndName); } else { // if in CLI mode then use shorter names so they are tab friendly in the shell dependencies.setItemLabelConverter(dto -> Commands.shellifyCommandName(dto.getName())); } dependencies.setValueConverter(s -> { for (SpringBootDependencyDTO dto : choices) { if (dto.getId().equals(s)) { return dto; } } return null; }); builder.add(springBootVersion).add(dependencies); }
/** * Shellifies a command name * * @param name * @return */ public static String shellifyCommandName(String name) { return shellifyName(name).toLowerCase(); }
dto -> Commands.shellifyCommandName(dto.getName()));
String shellName = shellifyName(name); StringBuilder sb = new StringBuilder(); for (int i = 0; i < shellName.length(); i++)