Tabnine Logo
CommandLine$Model$ParserSpec.unmatchedOptionsArePositionalParams
Code IndexAdd Tabnine to your IDE (free)

How to use
unmatchedOptionsArePositionalParams
method
in
picocli.CommandLine$Model$ParserSpec

Best Java code snippets using picocli.CommandLine$Model$ParserSpec.unmatchedOptionsArePositionalParams (Showing top 15 results out of 315)

origin: remkop/picocli

private void printParser(ParserSpec parser, PrintWriter pw, String indent) {
  pw.printf("%sParserSpec:%n", indent);
  indent += "  ";
  pw.printf("%sseparator: '%s'%n", indent, parser.separator());
  pw.printf("%sendOfOptionsDelimiter: '%s'%n", indent, parser.endOfOptionsDelimiter());
  pw.printf("%sexpandAtFiles: %s%n", indent, parser.expandAtFiles());
  pw.printf("%satFileCommentChar: '%s'%n", indent, parser.atFileCommentChar());
  pw.printf("%soverwrittenOptionsAllowed: %s%n", indent, parser.overwrittenOptionsAllowed());
  pw.printf("%sunmatchedArgumentsAllowed: %s%n", indent, parser.unmatchedArgumentsAllowed());
  pw.printf("%sunmatchedOptionsArePositionalParams: %s%n", indent, parser.unmatchedOptionsArePositionalParams());
  pw.printf("%sstopAtUnmatched: %s%n", indent, parser.stopAtUnmatched());
  pw.printf("%sstopAtPositional: %s%n", indent, parser.stopAtPositional());
  pw.printf("%sposixClusteredShortOptionsAllowed: %s%n", indent, parser.posixClusteredShortOptionsAllowed());
  pw.printf("%saritySatisfiedByAttachedOptionParam: %s%n", indent, parser.aritySatisfiedByAttachedOptionParam());
  pw.printf("%scaseInsensitiveEnumValuesAllowed: %s%n", indent, parser.caseInsensitiveEnumValuesAllowed());
  pw.printf("%scollectErrors: %s%n", indent, parser.collectErrors());
  pw.printf("%slimitSplit: %s%n", indent, parser.limitSplit());
  pw.printf("%stoggleBooleanFlags: %s%n", indent, parser.toggleBooleanFlags());
}
origin: remkop/picocli

  boolean resemblesOption(String arg, Tracer tracer) {
    if (parser().unmatchedOptionsArePositionalParams()) {
      if (tracer != null && tracer.isDebug()) {tracer.debug("Parser is configured to treat all unmatched options as positional parameter%n", arg);}
      return false;
    }
    if (arg.length() == 1) {
      if (tracer != null && tracer.isDebug()) {tracer.debug("Single-character arguments that don't match known options are considered positional parameters%n", arg);}
      return false;
    }
    if (options().isEmpty()) {
      boolean result = arg.startsWith("-");
      if (tracer != null && tracer.isDebug()) {tracer.debug("'%s' %s an option%n", arg, (result ? "resembles" : "doesn't resemble"));}
      return result;
    }
    int count = 0;
    for (String optionName : optionsMap().keySet()) {
      for (int i = 0; i < arg.length(); i++) {
        if (optionName.length() > i && arg.charAt(i) == optionName.charAt(i)) { count++; } else { break; }
      }
    }
    boolean result = count > 0 && count * 10 >= optionsMap().size() * 9; // at least one prefix char in common with 9 out of 10 options
    if (tracer != null && tracer.isDebug()) {tracer.debug("'%s' %s an option: %d matching prefix chars out of %d option names%n", arg, (result ? "resembles" : "doesn't resemble"), count, optionsMap().size());}
    return result;
  }
}
origin: remkop/picocli

/** Sets whether arguments on the command line that resemble an option should be treated as positional parameters.
 * The default is {@code false}.
 * <p>The specified setting will be registered with this {@code CommandLine} and the full hierarchy of its
 * subcommands and nested sub-subcommands <em>at the moment this method is called</em>. Subcommands added
 * later will have the default setting. To ensure a setting is applied to all
 * subcommands, call the setter last, after adding subcommands.</p>
 * @param newValue the new setting. When {@code true}, arguments on the command line that resemble an option should be treated as positional parameters.
 * @return this {@code CommandLine} object, to allow method chaining
 * @since 3.0
 * @see #getUnmatchedArguments()
 * @see #isUnmatchedArgumentsAllowed
 */
public CommandLine setUnmatchedOptionsArePositionalParams(boolean newValue) {
  getCommandSpec().parser().unmatchedOptionsArePositionalParams(newValue);
  for (CommandLine command : getCommandSpec().subcommands().values()) {
    command.setUnmatchedOptionsArePositionalParams(newValue);
  }
  return this;
}
origin: hazelcast/hazelcast-jet

  boolean resemblesOption(String arg, Tracer tracer) {
    if (parser().unmatchedOptionsArePositionalParams()) {
      if (tracer != null && tracer.isDebug()) {tracer.debug("Parser is configured to treat all unmatched options as positional parameter%n", arg);}
      return false;
    }
    if (options().isEmpty()) {
      boolean result = arg.startsWith("-");
      if (tracer != null && tracer.isDebug()) {tracer.debug("%s %s an option%n", arg, (result ? "resembles" : "doesn't resemble"));}
      return result;
    }
    int count = 0;
    for (String optionName : optionsMap().keySet()) {
      for (int i = 0; i < arg.length(); i++) {
        if (optionName.length() > i && arg.charAt(i) == optionName.charAt(i)) { count++; } else { break; }
      }
    }
    boolean result = count > 0 && count * 10 >= optionsMap().size() * 9; // at least one prefix char in common with 9 out of 10 options
    if (tracer != null && tracer.isDebug()) {tracer.debug("%s %s an option: %d matching prefix chars out of %d option names%n", arg, (result ? "resembles" : "doesn't resemble"), count, optionsMap().size());}
    return result;
  }
}
origin: hazelcast/hazelcast-jet

/** Sets whether arguments on the command line that resemble an option should be treated as positional parameters.
 * The default is {@code false}.
 * <p>The specified setting will be registered with this {@code CommandLine} and the full hierarchy of its
 * subcommands and nested sub-subcommands <em>at the moment this method is called</em>. Subcommands added
 * later will have the default setting. To ensure a setting is applied to all
 * subcommands, call the setter last, after adding subcommands.</p>
 * @param newValue the new setting. When {@code true}, arguments on the command line that resemble an option should be treated as positional parameters.
 * @return this {@code CommandLine} object, to allow method chaining
 * @since 3.0
 * @see #getUnmatchedArguments()
 * @see #isUnmatchedArgumentsAllowed
 */
public CommandLine setUnmatchedOptionsArePositionalParams(boolean newValue) {
  getCommandSpec().parser().unmatchedOptionsArePositionalParams(newValue);
  for (CommandLine command : getCommandSpec().subcommands().values()) {
    command.setUnmatchedOptionsArePositionalParams(newValue);
  }
  return this;
}
origin: info.picocli/picocli

@Test
public void testResemblesOption_WithOptionsNonDash() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  spec.addOption(OptionSpec.builder("/x").build());
  spec.parser().unmatchedOptionsArePositionalParams(false);
  assertFalse(spec.resemblesOption("blah", null));
  System.setProperty("picocli.trace", "DEBUG");
  Tracer tracer = new Tracer();
  System.clearProperty("picocli.trace");
  assertFalse(spec.resemblesOption("blah", tracer));
  assertFalse(spec.resemblesOption("-a", tracer));
  assertTrue(spec.resemblesOption("/a", tracer));
  Tracer tracer2 = new Tracer();
  assertFalse(spec.resemblesOption("blah", tracer2));
  assertFalse(spec.resemblesOption("-a", tracer));
  assertTrue(spec.resemblesOption("/a", tracer));
}
origin: info.picocli/picocli

@Test
public void testResemblesOption_WithOptionsDash() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  spec.addOption(OptionSpec.builder("-x").build());
  spec.parser().unmatchedOptionsArePositionalParams(false);
  assertFalse(spec.resemblesOption("blah", null));
  System.setProperty("picocli.trace", "DEBUG");
  Tracer tracer = new Tracer();
  System.clearProperty("picocli.trace");
  assertFalse(spec.resemblesOption("blah", tracer));
  assertTrue(spec.resemblesOption("-a", tracer));
  assertFalse(spec.resemblesOption("/a", tracer));
  Tracer tracer2 = new Tracer();
  assertFalse(spec.resemblesOption("blah", tracer2));
  assertTrue(spec.resemblesOption("-a", tracer));
  assertFalse(spec.resemblesOption("/a", tracer));
}
origin: info.picocli/picocli

@Test
public void testResemblesOption_WithoutOptions() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  spec.parser().unmatchedOptionsArePositionalParams(false);
  assertFalse(spec.resemblesOption("blah", null));
  System.setProperty("picocli.trace", "DEBUG");
  Tracer tracer = new Tracer();
  System.clearProperty("picocli.trace");
  assertFalse(spec.resemblesOption("blah", tracer));
  assertTrue(spec.resemblesOption("-a", tracer));
  Tracer tracer2 = new Tracer();
  assertFalse(spec.resemblesOption("blah", tracer2));
  assertTrue(spec.resemblesOption("-a", tracer));
}
origin: info.picocli/picocli

@Test
public void testResemblesOption_WhenUnmatchedArePositional() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  spec.parser().unmatchedOptionsArePositionalParams(true);
  assertFalse(spec.resemblesOption("blah", null));
  System.setProperty("picocli.trace", "DEBUG");
  Tracer tracer = new Tracer();
  System.clearProperty("picocli.trace");
  assertFalse(spec.resemblesOption("blah", tracer));
  Tracer tracer2 = new Tracer();
  assertFalse(spec.resemblesOption("blah", tracer2));
}
origin: hazelcast/hazelcast-jet

/** Returns whether arguments on the command line that resemble an option should be treated as positional parameters.
 * The default is {@code false} and the parser behaviour depends on {@link #isUnmatchedArgumentsAllowed()}.
 * @return {@code true} arguments on the command line that resemble an option should be treated as positional parameters, {@code false} otherwise
 * @see #getUnmatchedArguments()
 * @since 3.0
 */
public boolean isUnmatchedOptionsArePositionalParams() {
  return getCommandSpec().parser().unmatchedOptionsArePositionalParams();
}
origin: remkop/picocli

@Test
public void testResemblesOption_WithOptionsDash() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  spec.addOption(OptionSpec.builder("-x").build());
  spec.parser().unmatchedOptionsArePositionalParams(false);
  assertFalse(spec.resemblesOption("blah", null));
  System.setProperty("picocli.trace", "DEBUG");
  Tracer tracer = new Tracer();
  System.clearProperty("picocli.trace");
  assertFalse(spec.resemblesOption("blah", tracer));
  assertTrue(spec.resemblesOption("-a", tracer));
  assertFalse(spec.resemblesOption("/a", tracer));
  Tracer tracer2 = new Tracer();
  assertFalse(spec.resemblesOption("blah", tracer2));
  assertTrue(spec.resemblesOption("-a", tracer));
  assertFalse(spec.resemblesOption("/a", tracer));
}
origin: remkop/picocli

@Test
public void testResemblesOption_WithOptionsNonDash() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  spec.addOption(OptionSpec.builder("/x").build());
  spec.parser().unmatchedOptionsArePositionalParams(false);
  assertFalse(spec.resemblesOption("blah", null));
  System.setProperty("picocli.trace", "DEBUG");
  Tracer tracer = new Tracer();
  System.clearProperty("picocli.trace");
  assertFalse(spec.resemblesOption("blah", tracer));
  assertFalse(spec.resemblesOption("-a", tracer));
  assertTrue(spec.resemblesOption("/a", tracer));
  Tracer tracer2 = new Tracer();
  assertFalse(spec.resemblesOption("blah", tracer2));
  assertFalse(spec.resemblesOption("-a", tracer));
  assertTrue(spec.resemblesOption("/a", tracer));
}
origin: remkop/picocli

@Test
public void testResemblesOption_WithoutOptions() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  spec.parser().unmatchedOptionsArePositionalParams(false);
  assertFalse(spec.resemblesOption("blah", null));
  System.setProperty("picocli.trace", "DEBUG");
  Tracer tracer = new Tracer();
  System.clearProperty("picocli.trace");
  assertFalse(spec.resemblesOption("blah", tracer));
  assertTrue(spec.resemblesOption("-a", tracer));
  Tracer tracer2 = new Tracer();
  assertFalse(spec.resemblesOption("blah", tracer2));
  assertTrue(spec.resemblesOption("-a", tracer));
}
origin: remkop/picocli

/** Returns whether arguments on the command line that resemble an option should be treated as positional parameters.
 * The default is {@code false} and the parser behaviour depends on {@link #isUnmatchedArgumentsAllowed()}.
 * @return {@code true} arguments on the command line that resemble an option should be treated as positional parameters, {@code false} otherwise
 * @see #getUnmatchedArguments()
 * @since 3.0
 */
public boolean isUnmatchedOptionsArePositionalParams() {
  return getCommandSpec().parser().unmatchedOptionsArePositionalParams();
}
origin: remkop/picocli

@Test
public void testResemblesOption_WhenUnmatchedArePositional() {
  CommandSpec spec = CommandSpec.wrapWithoutInspection(null);
  spec.parser().unmatchedOptionsArePositionalParams(true);
  assertFalse(spec.resemblesOption("blah", null));
  System.setProperty("picocli.trace", "DEBUG");
  Tracer tracer = new Tracer();
  System.clearProperty("picocli.trace");
  assertFalse(spec.resemblesOption("blah", tracer));
  Tracer tracer2 = new Tracer();
  assertFalse(spec.resemblesOption("blah", tracer2));
}
picocliCommandLine$Model$ParserSpecunmatchedOptionsArePositionalParams

Popular methods of CommandLine$Model$ParserSpec

  • separator
  • aritySatisfiedByAttachedOptionParam
  • caseInsensitiveEnumValuesAllowed
  • collectErrors
  • limitSplit
  • posixClusteredShortOptionsAllowed
  • splitQuotedStrings
  • trimQuotes
  • useSimplifiedAtFiles
  • atFileCommentChar
  • endOfOptionsDelimiter
  • expandAtFiles
  • endOfOptionsDelimiter,
  • expandAtFiles,
  • overwrittenOptionsAllowed,
  • stopAtPositional,
  • stopAtUnmatched,
  • toggleBooleanFlags,
  • unmatchedArgumentsAllowed,
  • <init>,
  • initFrom

Popular in Java

  • Creating JSON documents from java classes using gson
  • notifyDataSetChanged (ArrayAdapter)
  • getResourceAsStream (ClassLoader)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now