private static CommandSpec findCommandFor(ArgSpec arg, CommandSpec cmd) { return (arg instanceof OptionSpec) ? findCommandFor((OptionSpec) arg, cmd) : findCommandFor((PositionalParamSpec) arg, cmd); } private static CommandSpec findCommandFor(OptionSpec option, CommandSpec commandSpec) {
private static CommandSpec findCommandFor(PositionalParamSpec positional, CommandSpec commandSpec) { for (PositionalParamSpec defined : commandSpec.positionalParameters()) { if (defined == positional) { return commandSpec; } } for (CommandLine sub : commandSpec.subcommands().values()) { CommandSpec result = findCommandFor(positional, sub.getCommandSpec()); if (result != null) { return result; } } return null; } private static boolean isPicocliModelObject(Object obj) {
private static CommandSpec findCommandFor(OptionSpec option, CommandSpec commandSpec) { for (OptionSpec defined : commandSpec.options()) { if (defined == option) { return commandSpec; } } for (CommandLine sub : commandSpec.subcommands().values()) { CommandSpec result = findCommandFor(option, sub.getCommandSpec()); if (result != null) { return result; } } return null; } private static CommandSpec findCommandFor(PositionalParamSpec positional, CommandSpec commandSpec) {
private static Object findCompletionStartPoint(ParseResult parseResult) { List<Object> tentativeMatches = parseResult.tentativeMatch; for (int i = 1; i <= tentativeMatches.size(); i++) { Object found = tentativeMatches.get(tentativeMatches.size() - i); if (found instanceof CommandSpec) { return found; } if (found instanceof ArgSpec) { CommandLine.Range arity = ((ArgSpec) found).arity(); if (i < arity.min) { return found; // not all parameters have been supplied yet } else { return findCommandFor((ArgSpec) found, parseResult.commandSpec()); } } } return parseResult.commandSpec(); }
int sep = currentArg.indexOf(spec.parser().separator()); if (sep < 0 || positionInArg < sep) { // no '=' or cursor before '=' addCandidatesForArgsFollowing(findCommandFor((OptionSpec) obj, spec), candidates); } else { addCandidatesForArgsFollowing((OptionSpec) obj, candidates); addCandidatesForArgsFollowing(findCommandFor((PositionalParamSpec) obj, spec), candidates);
private static CommandSpec findCommandFor(ArgSpec arg, CommandSpec cmd) { return (arg instanceof OptionSpec) ? findCommandFor((OptionSpec) arg, cmd) : findCommandFor((PositionalParamSpec) arg, cmd); } private static CommandSpec findCommandFor(OptionSpec option, CommandSpec commandSpec) {
private static CommandSpec findCommandFor(OptionSpec option, CommandSpec commandSpec) { for (OptionSpec defined : commandSpec.options()) { if (defined == option) { return commandSpec; } } for (CommandLine sub : commandSpec.subcommands().values()) { CommandSpec result = findCommandFor(option, sub.getCommandSpec()); if (result != null) { return result; } } return null; } private static CommandSpec findCommandFor(PositionalParamSpec positional, CommandSpec commandSpec) {
private static CommandSpec findCommandFor(PositionalParamSpec positional, CommandSpec commandSpec) { for (PositionalParamSpec defined : commandSpec.positionalParameters()) { if (defined == positional) { return commandSpec; } } for (CommandLine sub : commandSpec.subcommands().values()) { CommandSpec result = findCommandFor(positional, sub.getCommandSpec()); if (result != null) { return result; } } return null; } private static boolean isPicocliModelObject(Object obj) {
private static Object findCompletionStartPoint(ParseResult parseResult) { List<Object> tentativeMatches = parseResult.tentativeMatch; for (int i = 1; i <= tentativeMatches.size(); i++) { Object found = tentativeMatches.get(tentativeMatches.size() - i); if (found instanceof CommandSpec) { return found; } if (found instanceof ArgSpec) { CommandLine.Range arity = ((ArgSpec) found).arity(); if (i < arity.min) { return found; // not all parameters have been supplied yet } else { return findCommandFor((ArgSpec) found, parseResult.commandSpec()); } } } return parseResult.commandSpec(); }
int sep = currentArg.indexOf(spec.parser().separator()); if (sep < 0 || positionInArg < sep) { // no '=' or cursor before '=' addCandidatesForArgsFollowing(findCommandFor((OptionSpec) obj, spec), candidates); } else { addCandidatesForArgsFollowing((OptionSpec) obj, candidates); addCandidatesForArgsFollowing(findCommandFor((PositionalParamSpec) obj, spec), candidates);