Java Code Examples for picocli.CommandLine.Model.OptionSpec#hidden()
The following examples show how to use
picocli.CommandLine.Model.OptionSpec#hidden() .
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: AutoComplete.java From picocli with Apache License 2.0 | 5 votes |
private static String generateOptionsCases(List<OptionSpec> argOptionFields, String indent, String currWord) { StringBuilder buff = new StringBuilder(1024); for (OptionSpec option : argOptionFields) { if (option.hidden()) { continue; } // #887 skip hidden options Class<?> type = option.type(); if (option.typeInfo().isMultiValue()){ type = option.typeInfo().getAuxiliaryTypes()[0]; } if (option.completionCandidates() != null) { buff.append(format("%s %s)\n", indent, concat("|", option.names()))); // " -u|--timeUnit)\n" buff.append(format("%s COMPREPLY=( $( compgen -W \"${%s_option_args}\" -- \"%s\" ) )\n", indent, bashify(option.paramLabel()), currWord)); buff.append(format("%s return $?\n", indent)); buff.append(format("%s ;;\n", indent)); } else if (type.equals(File.class) || "java.nio.file.Path".equals(type.getName())) { buff.append(format("%s %s)\n", indent, concat("|", option.names()))); // " -f|--file)\n" buff.append(format("%s compopt -o filenames\n", indent)); buff.append(format("%s COMPREPLY=( $( compgen -f -- \"%s\" ) ) # files\n", indent, currWord)); buff.append(format("%s return $?\n", indent)); buff.append(format("%s ;;\n", indent)); } else if (type.equals(InetAddress.class)) { buff.append(format("%s %s)\n", indent, concat("|", option.names()))); // " -h|--host)\n" buff.append(format("%s compopt -o filenames\n", indent)); buff.append(format("%s COMPREPLY=( $( compgen -A hostname -- \"%s\" ) )\n", indent, currWord)); buff.append(format("%s return $?\n", indent)); buff.append(format("%s ;;\n", indent)); } else { buff.append(format("%s %s)\n", indent, concat("|", option.names()))); // no completions available buff.append(format("%s return\n", indent)); buff.append(format("%s ;;\n", indent)); } } return buff.toString(); }
Example 2
Source File: AutoComplete.java From picocli with Apache License 2.0 | 5 votes |
private static String optionNames(List<OptionSpec> options) { List<String> result = new ArrayList<String>(); for (OptionSpec option : options) { if (option.hidden()) { continue; } // #887 skip hidden options result.addAll(Arrays.asList(option.names())); } return concat(" ", result, "", new NullFunction()).trim(); }
Example 3
Source File: AutoComplete.java From Flashtool with GNU General Public License v3.0 | 5 votes |
private static String generateOptionsCases(List<OptionSpec> argOptionFields, String indent, String currWord) { StringBuilder buff = new StringBuilder(1024); for (OptionSpec option : argOptionFields) { if (option.hidden()) { continue; } // #887 skip hidden options Class<?> type = option.type(); if (option.typeInfo().isMultiValue()){ type = option.typeInfo().getAuxiliaryTypes()[0]; } if (option.completionCandidates() != null) { buff.append(format("%s %s)\n", indent, concat("|", option.names()))); // " -u|--timeUnit)\n" buff.append(format("%s COMPREPLY=( $( compgen -W \"${%s_option_args}\" -- \"%s\" ) )\n", indent, bashify(option.paramLabel()), currWord)); buff.append(format("%s return $?\n", indent)); buff.append(format("%s ;;\n", indent)); } else if (type.equals(File.class) || "java.nio.file.Path".equals(type.getName())) { buff.append(format("%s %s)\n", indent, concat("|", option.names()))); // " -f|--file)\n" buff.append(format("%s compopt -o filenames\n", indent)); buff.append(format("%s COMPREPLY=( $( compgen -f -- \"%s\" ) ) # files\n", indent, currWord)); buff.append(format("%s return $?\n", indent)); buff.append(format("%s ;;\n", indent)); } else if (type.equals(InetAddress.class)) { buff.append(format("%s %s)\n", indent, concat("|", option.names()))); // " -h|--host)\n" buff.append(format("%s compopt -o filenames\n", indent)); buff.append(format("%s COMPREPLY=( $( compgen -A hostname -- \"%s\" ) )\n", indent, currWord)); buff.append(format("%s return $?\n", indent)); buff.append(format("%s ;;\n", indent)); } else { buff.append(format("%s %s)\n", indent, concat("|", option.names()))); // no completions available buff.append(format("%s return\n", indent)); buff.append(format("%s ;;\n", indent)); } } return buff.toString(); }
Example 4
Source File: AutoComplete.java From Flashtool with GNU General Public License v3.0 | 5 votes |
private static String optionNames(List<OptionSpec> options) { List<String> result = new ArrayList<String>(); for (OptionSpec option : options) { if (option.hidden()) { continue; } // #887 skip hidden options result.addAll(Arrays.asList(option.names())); } return concat(" ", result, "", new NullFunction()).trim(); }
Example 5
Source File: AutoComplete.java From picocli with Apache License 2.0 | 4 votes |
private static void addCandidatesForArgsFollowing(OptionSpec optionSpec, List<CharSequence> candidates) { if (optionSpec != null && !optionSpec.hidden()) { addCompletionCandidates(optionSpec.completionCandidates(), candidates); } }
Example 6
Source File: AutoComplete.java From Flashtool with GNU General Public License v3.0 | 4 votes |
private static void addCandidatesForArgsFollowing(OptionSpec optionSpec, List<CharSequence> candidates) { if (optionSpec != null && !optionSpec.hidden()) { addCompletionCandidates(optionSpec.completionCandidates(), candidates); } }