Java Code Examples for picocli.CommandLine.Model.PositionalParamSpec#completionCandidates()
The following examples show how to use
picocli.CommandLine.Model.PositionalParamSpec#completionCandidates() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandUtils.java From mcspring-boot with MIT License | 5 votes |
private static Stream<String> getSuggestedValues(PositionalParamSpec paramSpec) { Iterable<String> completionCandidates = paramSpec.completionCandidates(); if (completionCandidates != null) { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(completionCandidates.iterator(), 0), false); } else { return getSuggestedValues(paramSpec.type()); } }
Example 2
Source File: AutoComplete.java From picocli with Apache License 2.0 | 5 votes |
private static String generatePositionalParamsCases(List<PositionalParamSpec> posParams, String indent, String currWord) { StringBuilder buff = new StringBuilder(1024); for (PositionalParamSpec param : posParams) { if (param.hidden()) { continue; } // #887 skip hidden params Class<?> type = param.type(); if (param.typeInfo().isMultiValue()) { type = param.typeInfo().getAuxiliaryTypes()[0]; } String paramName = bashify(param.paramLabel()); String ifOrElif = buff.length() > 0 ? "elif" : "if"; int min = param.index().min(); int max = param.index().max(); if (param.completionCandidates() != null) { buff.append(format("%s %s (( currIndex >= %d && currIndex <= %d )); then\n", indent, ifOrElif, min, max)); buff.append(format("%s positionals=$( compgen -W \"$%s_pos_param_args\" -- \"%s\" )\n", indent, paramName, currWord)); } else if (type.equals(File.class) || "java.nio.file.Path".equals(type.getName())) { buff.append(format("%s %s (( currIndex >= %d && currIndex <= %d )); then\n", indent, ifOrElif, min, max)); buff.append(format("%s compopt -o filenames\n", indent)); buff.append(format("%s positionals=$( compgen -f -- \"%s\" ) # files\n", indent, currWord)); } else if (type.equals(InetAddress.class)) { buff.append(format("%s %s (( currIndex >= %d && currIndex <= %d )); then\n", indent, ifOrElif, min, max)); buff.append(format("%s compopt -o filenames\n", indent)); buff.append(format("%s positionals=$( compgen -A hostname -- \"%s\" )\n", indent, currWord)); } } if (buff.length() > 0) { buff.append(format("%s fi\n", indent)); } return buff.toString(); }
Example 3
Source File: AutoComplete.java From Flashtool with GNU General Public License v3.0 | 5 votes |
private static String generatePositionalParamsCases(List<PositionalParamSpec> posParams, String indent, String currWord) { StringBuilder buff = new StringBuilder(1024); for (PositionalParamSpec param : posParams) { if (param.hidden()) { continue; } // #887 skip hidden params Class<?> type = param.type(); if (param.typeInfo().isMultiValue()) { type = param.typeInfo().getAuxiliaryTypes()[0]; } String paramName = bashify(param.paramLabel()); String ifOrElif = buff.length() > 0 ? "elif" : "if"; int min = param.index().min(); int max = param.index().max(); if (param.completionCandidates() != null) { buff.append(format("%s %s (( currIndex >= %d && currIndex <= %d )); then\n", indent, ifOrElif, min, max)); buff.append(format("%s positionals=$( compgen -W \"$%s_pos_param_args\" -- \"%s\" )\n", indent, paramName, currWord)); } else if (type.equals(File.class) || "java.nio.file.Path".equals(type.getName())) { buff.append(format("%s %s (( currIndex >= %d && currIndex <= %d )); then\n", indent, ifOrElif, min, max)); buff.append(format("%s compopt -o filenames\n", indent)); buff.append(format("%s positionals=$( compgen -f -- \"%s\" ) # files\n", indent, currWord)); } else if (type.equals(InetAddress.class)) { buff.append(format("%s %s (( currIndex >= %d && currIndex <= %d )); then\n", indent, ifOrElif, min, max)); buff.append(format("%s compopt -o filenames\n", indent)); buff.append(format("%s positionals=$( compgen -A hostname -- \"%s\" )\n", indent, currWord)); } } if (buff.length() > 0) { buff.append(format("%s fi\n", indent)); } return buff.toString(); }