blob: 5651621b796bb69d69447f19783587880a7147db [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>CommandLine xref</title>
<link type="text/css" rel="stylesheet" href="../../../../../../../stylesheet.css" />
</head>
<body>
<div id="overview"><a href="../../../../../../../../apidocs/org/apache/logging/log4j/core/tools/picocli/CommandLine.html">View Javadoc</a></div><pre>
<a class="jxr_linenumber" name="L1" href="#L1">1</a> <em class="jxr_comment">/*</em>
<a class="jxr_linenumber" name="L2" href="#L2">2</a> <em class="jxr_comment"> * Licensed to the Apache Software Foundation (ASF) under one or more</em>
<a class="jxr_linenumber" name="L3" href="#L3">3</a> <em class="jxr_comment"> * contributor license agreements. See the NOTICE file distributed with</em>
<a class="jxr_linenumber" name="L4" href="#L4">4</a> <em class="jxr_comment"> * this work for additional information regarding copyright ownership.</em>
<a class="jxr_linenumber" name="L5" href="#L5">5</a> <em class="jxr_comment"> * The ASF licenses this file to You under the Apache license, Version 2.0</em>
<a class="jxr_linenumber" name="L6" href="#L6">6</a> <em class="jxr_comment"> * (the "License"); you may not use this file except in compliance with</em>
<a class="jxr_linenumber" name="L7" href="#L7">7</a> <em class="jxr_comment"> * the License. You may obtain a copy of the License at</em>
<a class="jxr_linenumber" name="L8" href="#L8">8</a> <em class="jxr_comment"> *</em>
<a class="jxr_linenumber" name="L9" href="#L9">9</a> <em class="jxr_comment"> * <a href="http://www.apache.org/licenses/LICENSE-2." target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.</a>0</em>
<a class="jxr_linenumber" name="L10" href="#L10">10</a> <em class="jxr_comment"> *</em>
<a class="jxr_linenumber" name="L11" href="#L11">11</a> <em class="jxr_comment"> * Unless required by applicable law or agreed to in writing, software</em>
<a class="jxr_linenumber" name="L12" href="#L12">12</a> <em class="jxr_comment"> * distributed under the License is distributed on an "AS IS" BASIS,</em>
<a class="jxr_linenumber" name="L13" href="#L13">13</a> <em class="jxr_comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em>
<a class="jxr_linenumber" name="L14" href="#L14">14</a> <em class="jxr_comment"> * See the license for the specific language governing permissions and</em>
<a class="jxr_linenumber" name="L15" href="#L15">15</a> <em class="jxr_comment"> * limitations under the license.</em>
<a class="jxr_linenumber" name="L16" href="#L16">16</a> <em class="jxr_comment"> */</em>
<a class="jxr_linenumber" name="L17" href="#L17">17</a> <strong class="jxr_keyword">package</strong> org.apache.logging.log4j.core.tools.picocli;
<a class="jxr_linenumber" name="L18" href="#L18">18</a>
<a class="jxr_linenumber" name="L19" href="#L19">19</a> <strong class="jxr_keyword">import</strong> java.io.File;
<a class="jxr_linenumber" name="L20" href="#L20">20</a> <strong class="jxr_keyword">import</strong> java.io.PrintStream;
<a class="jxr_linenumber" name="L21" href="#L21">21</a> <strong class="jxr_keyword">import</strong> java.lang.annotation.ElementType;
<a class="jxr_linenumber" name="L22" href="#L22">22</a> <strong class="jxr_keyword">import</strong> java.lang.annotation.Retention;
<a class="jxr_linenumber" name="L23" href="#L23">23</a> <strong class="jxr_keyword">import</strong> java.lang.annotation.RetentionPolicy;
<a class="jxr_linenumber" name="L24" href="#L24">24</a> <strong class="jxr_keyword">import</strong> java.lang.annotation.Target;
<a class="jxr_linenumber" name="L25" href="#L25">25</a> <strong class="jxr_keyword">import</strong> java.lang.reflect.Array;
<a class="jxr_linenumber" name="L26" href="#L26">26</a> <strong class="jxr_keyword">import</strong> java.lang.reflect.Constructor;
<a class="jxr_linenumber" name="L27" href="#L27">27</a> <strong class="jxr_keyword">import</strong> java.lang.reflect.Field;
<a class="jxr_linenumber" name="L28" href="#L28">28</a> <strong class="jxr_keyword">import</strong> java.lang.reflect.ParameterizedType;
<a class="jxr_linenumber" name="L29" href="#L29">29</a> <strong class="jxr_keyword">import</strong> java.lang.reflect.Type;
<a class="jxr_linenumber" name="L30" href="#L30">30</a> <strong class="jxr_keyword">import</strong> java.lang.reflect.WildcardType;
<a class="jxr_linenumber" name="L31" href="#L31">31</a> <strong class="jxr_keyword">import</strong> java.math.BigDecimal;
<a class="jxr_linenumber" name="L32" href="#L32">32</a> <strong class="jxr_keyword">import</strong> java.math.BigInteger;
<a class="jxr_linenumber" name="L33" href="#L33">33</a> <strong class="jxr_keyword">import</strong> java.net.InetAddress;
<a class="jxr_linenumber" name="L34" href="#L34">34</a> <strong class="jxr_keyword">import</strong> java.net.MalformedURLException;
<a class="jxr_linenumber" name="L35" href="#L35">35</a> <strong class="jxr_keyword">import</strong> java.net.URI;
<a class="jxr_linenumber" name="L36" href="#L36">36</a> <strong class="jxr_keyword">import</strong> java.net.URISyntaxException;
<a class="jxr_linenumber" name="L37" href="#L37">37</a> <strong class="jxr_keyword">import</strong> java.net.URL;
<a class="jxr_linenumber" name="L38" href="#L38">38</a> <strong class="jxr_keyword">import</strong> java.nio.charset.Charset;
<a class="jxr_linenumber" name="L39" href="#L39">39</a> <strong class="jxr_keyword">import</strong> java.nio.file.Path;
<a class="jxr_linenumber" name="L40" href="#L40">40</a> <strong class="jxr_keyword">import</strong> java.nio.file.Paths;
<a class="jxr_linenumber" name="L41" href="#L41">41</a> <strong class="jxr_keyword">import</strong> java.sql.Time;
<a class="jxr_linenumber" name="L42" href="#L42">42</a> <strong class="jxr_keyword">import</strong> java.text.BreakIterator;
<a class="jxr_linenumber" name="L43" href="#L43">43</a> <strong class="jxr_keyword">import</strong> java.text.ParseException;
<a class="jxr_linenumber" name="L44" href="#L44">44</a> <strong class="jxr_keyword">import</strong> java.text.SimpleDateFormat;
<a class="jxr_linenumber" name="L45" href="#L45">45</a> <strong class="jxr_keyword">import</strong> java.util.ArrayList;
<a class="jxr_linenumber" name="L46" href="#L46">46</a> <strong class="jxr_keyword">import</strong> java.util.Arrays;
<a class="jxr_linenumber" name="L47" href="#L47">47</a> <strong class="jxr_keyword">import</strong> java.util.Collection;
<a class="jxr_linenumber" name="L48" href="#L48">48</a> <strong class="jxr_keyword">import</strong> java.util.Collections;
<a class="jxr_linenumber" name="L49" href="#L49">49</a> <strong class="jxr_keyword">import</strong> java.util.Comparator;
<a class="jxr_linenumber" name="L50" href="#L50">50</a> <strong class="jxr_keyword">import</strong> java.util.Date;
<a class="jxr_linenumber" name="L51" href="#L51">51</a> <strong class="jxr_keyword">import</strong> java.util.HashMap;
<a class="jxr_linenumber" name="L52" href="#L52">52</a> <strong class="jxr_keyword">import</strong> java.util.HashSet;
<a class="jxr_linenumber" name="L53" href="#L53">53</a> <strong class="jxr_keyword">import</strong> java.util.LinkedHashMap;
<a class="jxr_linenumber" name="L54" href="#L54">54</a> <strong class="jxr_keyword">import</strong> java.util.LinkedHashSet;
<a class="jxr_linenumber" name="L55" href="#L55">55</a> <strong class="jxr_keyword">import</strong> java.util.LinkedList;
<a class="jxr_linenumber" name="L56" href="#L56">56</a> <strong class="jxr_keyword">import</strong> java.util.List;
<a class="jxr_linenumber" name="L57" href="#L57">57</a> <strong class="jxr_keyword">import</strong> java.util.Map;
<a class="jxr_linenumber" name="L58" href="#L58">58</a> <strong class="jxr_keyword">import</strong> java.util.Queue;
<a class="jxr_linenumber" name="L59" href="#L59">59</a> <strong class="jxr_keyword">import</strong> java.util.Set;
<a class="jxr_linenumber" name="L60" href="#L60">60</a> <strong class="jxr_keyword">import</strong> java.util.SortedSet;
<a class="jxr_linenumber" name="L61" href="#L61">61</a> <strong class="jxr_keyword">import</strong> java.util.Stack;
<a class="jxr_linenumber" name="L62" href="#L62">62</a> <strong class="jxr_keyword">import</strong> java.util.TreeSet;
<a class="jxr_linenumber" name="L63" href="#L63">63</a> <strong class="jxr_keyword">import</strong> java.util.UUID;
<a class="jxr_linenumber" name="L64" href="#L64">64</a> <strong class="jxr_keyword">import</strong> java.util.concurrent.Callable;
<a class="jxr_linenumber" name="L65" href="#L65">65</a> <strong class="jxr_keyword">import</strong> java.util.regex.Pattern;
<a class="jxr_linenumber" name="L66" href="#L66">66</a>
<a class="jxr_linenumber" name="L67" href="#L67">67</a> <strong class="jxr_keyword">import</strong> org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Ansi.IStyle;
<a class="jxr_linenumber" name="L68" href="#L68">68</a> <strong class="jxr_keyword">import</strong> org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Ansi.Style;
<a class="jxr_linenumber" name="L69" href="#L69">69</a> <strong class="jxr_keyword">import</strong> org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Ansi.Text;
<a class="jxr_linenumber" name="L70" href="#L70">70</a>
<a class="jxr_linenumber" name="L71" href="#L71">71</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> java.util.Locale.ENGLISH;
<a class="jxr_linenumber" name="L72" href="#L72">72</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Column.Overflow.SPAN;
<a class="jxr_linenumber" name="L73" href="#L73">73</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Column.Overflow.TRUNCATE;
<a class="jxr_linenumber" name="L74" href="#L74">74</a> <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.apache.logging.log4j.core.tools.picocli.CommandLine.Help.Column.Overflow.WRAP;
<a class="jxr_linenumber" name="L75" href="#L75">75</a>
<a class="jxr_linenumber" name="L76" href="#L76">76</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L77" href="#L77">77</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L78" href="#L78">78</a> <em class="jxr_javadoccomment"> * CommandLine interpreter that uses reflection to initialize an annotated domain object with values obtained from the</em>
<a class="jxr_linenumber" name="L79" href="#L79">79</a> <em class="jxr_javadoccomment"> * command line arguments.</em>
<a class="jxr_linenumber" name="L80" href="#L80">80</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;h2&gt;Example&lt;/h2&gt;</em>
<a class="jxr_linenumber" name="L81" href="#L81">81</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;import static picocli.CommandLine.*;</em>
<a class="jxr_linenumber" name="L82" href="#L82">82</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L83" href="#L83">83</a> <em class="jxr_javadoccomment"> * &amp;#064;Command(header = "Encrypt FILE(s), or standard input, to standard output or to the output file.",</em>
<a class="jxr_linenumber" name="L84" href="#L84">84</a> <em class="jxr_javadoccomment"> * version = "v1.2.3")</em>
<a class="jxr_linenumber" name="L85" href="#L85">85</a> <em class="jxr_javadoccomment"> * public class Encrypt {</em>
<a class="jxr_linenumber" name="L86" href="#L86">86</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L87" href="#L87">87</a> <em class="jxr_javadoccomment"> * &amp;#064;Parameters(type = File.class, description = "Any number of input files")</em>
<a class="jxr_linenumber" name="L88" href="#L88">88</a> <em class="jxr_javadoccomment"> * private List&amp;lt;File&amp;gt; files = new ArrayList&amp;lt;File&amp;gt;();</em>
<a class="jxr_linenumber" name="L89" href="#L89">89</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L90" href="#L90">90</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-o", "--out" }, description = "Output file (default: print to console)")</em>
<a class="jxr_linenumber" name="L91" href="#L91">91</a> <em class="jxr_javadoccomment"> * private File outputFile;</em>
<a class="jxr_linenumber" name="L92" href="#L92">92</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L93" href="#L93">93</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-v", "--verbose"}, description = "Verbosely list files processed")</em>
<a class="jxr_linenumber" name="L94" href="#L94">94</a> <em class="jxr_javadoccomment"> * private boolean verbose;</em>
<a class="jxr_linenumber" name="L95" href="#L95">95</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L96" href="#L96">96</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-h", "--help", "-?", "-help"}, usageHelp = true, description = "Display this help and exit")</em>
<a class="jxr_linenumber" name="L97" href="#L97">97</a> <em class="jxr_javadoccomment"> * private boolean help;</em>
<a class="jxr_linenumber" name="L98" href="#L98">98</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L99" href="#L99">99</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-V", "--version"}, versionHelp = true, description = "Display version info and exit")</em>
<a class="jxr_linenumber" name="L100" href="#L100">100</a> <em class="jxr_javadoccomment"> * private boolean versionHelp;</em>
<a class="jxr_linenumber" name="L101" href="#L101">101</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L102" href="#L102">102</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L103" href="#L103">103</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L104" href="#L104">104</a> <em class="jxr_javadoccomment"> * Use {@code CommandLine} to initialize a domain object as follows:</em>
<a class="jxr_linenumber" name="L105" href="#L105">105</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;pre&gt;</em>
<a class="jxr_linenumber" name="L106" href="#L106">106</a> <em class="jxr_javadoccomment"> * public static void main(String... args) {</em>
<a class="jxr_linenumber" name="L107" href="#L107">107</a> <em class="jxr_javadoccomment"> * Encrypt encrypt = new Encrypt();</em>
<a class="jxr_linenumber" name="L108" href="#L108">108</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L109" href="#L109">109</a> <em class="jxr_javadoccomment"> * List&amp;lt;CommandLine&amp;gt; parsedCommands = new CommandLine(encrypt).parse(args);</em>
<a class="jxr_linenumber" name="L110" href="#L110">110</a> <em class="jxr_javadoccomment"> * if (!CommandLine.printHelpIfRequested(parsedCommands, System.err, Help.Ansi.AUTO)) {</em>
<a class="jxr_linenumber" name="L111" href="#L111">111</a> <em class="jxr_javadoccomment"> * runProgram(encrypt);</em>
<a class="jxr_linenumber" name="L112" href="#L112">112</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L113" href="#L113">113</a> <em class="jxr_javadoccomment"> * } catch (ParameterException ex) { // command line arguments could not be parsed</em>
<a class="jxr_linenumber" name="L114" href="#L114">114</a> <em class="jxr_javadoccomment"> * System.err.println(ex.getMessage());</em>
<a class="jxr_linenumber" name="L115" href="#L115">115</a> <em class="jxr_javadoccomment"> * ex.getCommandLine().usage(System.err);</em>
<a class="jxr_linenumber" name="L116" href="#L116">116</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L117" href="#L117">117</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L118" href="#L118">118</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L119" href="#L119">119</a> <em class="jxr_javadoccomment"> * Invoke the above program with some command line arguments. The below are all equivalent:</em>
<a class="jxr_linenumber" name="L120" href="#L120">120</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L121" href="#L121">121</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L122" href="#L122">122</a> <em class="jxr_javadoccomment"> * --verbose --out=outfile in1 in2</em>
<a class="jxr_linenumber" name="L123" href="#L123">123</a> <em class="jxr_javadoccomment"> * --verbose --out outfile in1 in2</em>
<a class="jxr_linenumber" name="L124" href="#L124">124</a> <em class="jxr_javadoccomment"> * -v --out=outfile in1 in2</em>
<a class="jxr_linenumber" name="L125" href="#L125">125</a> <em class="jxr_javadoccomment"> * -v -o outfile in1 in2</em>
<a class="jxr_linenumber" name="L126" href="#L126">126</a> <em class="jxr_javadoccomment"> * -v -o=outfile in1 in2</em>
<a class="jxr_linenumber" name="L127" href="#L127">127</a> <em class="jxr_javadoccomment"> * -vo outfile in1 in2</em>
<a class="jxr_linenumber" name="L128" href="#L128">128</a> <em class="jxr_javadoccomment"> * -vo=outfile in1 in2</em>
<a class="jxr_linenumber" name="L129" href="#L129">129</a> <em class="jxr_javadoccomment"> * -v -ooutfile in1 in2</em>
<a class="jxr_linenumber" name="L130" href="#L130">130</a> <em class="jxr_javadoccomment"> * -vooutfile in1 in2</em>
<a class="jxr_linenumber" name="L131" href="#L131">131</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L132" href="#L132">132</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L133" href="#L133">133</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> {
<a class="jxr_linenumber" name="L134" href="#L134">134</a> <em class="jxr_javadoccomment">/** This is picocli version {@value}. */</em>
<a class="jxr_linenumber" name="L135" href="#L135">135</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> String VERSION = <span class="jxr_string">"2.0.3"</span>;
<a class="jxr_linenumber" name="L136" href="#L136">136</a>
<a class="jxr_linenumber" name="L137" href="#L137">137</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Tracer</a> tracer = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Tracer</a>();
<a class="jxr_linenumber" name="L138" href="#L138">138</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Interpreter</a> interpreter;
<a class="jxr_linenumber" name="L139" href="#L139">139</a> <strong class="jxr_keyword">private</strong> String commandName = Help.DEFAULT_COMMAND_NAME;
<a class="jxr_linenumber" name="L140" href="#L140">140</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> overwrittenOptionsAllowed = false;
<a class="jxr_linenumber" name="L141" href="#L141">141</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> unmatchedArgumentsAllowed = false;
<a class="jxr_linenumber" name="L142" href="#L142">142</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> List&lt;String&gt; unmatchedArguments = <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;();
<a class="jxr_linenumber" name="L143" href="#L143">143</a> <strong class="jxr_keyword">private</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> parent;
<a class="jxr_linenumber" name="L144" href="#L144">144</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> usageHelpRequested;
<a class="jxr_linenumber" name="L145" href="#L145">145</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> versionHelpRequested;
<a class="jxr_linenumber" name="L146" href="#L146">146</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> List&lt;String&gt; versionLines = <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;();
<a class="jxr_linenumber" name="L147" href="#L147">147</a>
<a class="jxr_linenumber" name="L148" href="#L148">148</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L149" href="#L149">149</a> <em class="jxr_javadoccomment"> * Constructs a new {@code CommandLine} interpreter with the specified annotated object.</em>
<a class="jxr_linenumber" name="L150" href="#L150">150</a> <em class="jxr_javadoccomment"> * When the {@link #parse(String...)} method is called, fields of the specified object that are annotated</em>
<a class="jxr_linenumber" name="L151" href="#L151">151</a> <em class="jxr_javadoccomment"> * with {@code @Option} or {@code @Parameters} will be initialized based on command line arguments.</em>
<a class="jxr_linenumber" name="L152" href="#L152">152</a> <em class="jxr_javadoccomment"> * @param command the object to initialize from the command line arguments</em>
<a class="jxr_linenumber" name="L153" href="#L153">153</a> <em class="jxr_javadoccomment"> * @throws InitializationException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L154" href="#L154">154</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L155" href="#L155">155</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a>(<strong class="jxr_keyword">final</strong> Object command) {
<a class="jxr_linenumber" name="L156" href="#L156">156</a> interpreter = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Interpreter</a>(command);
<a class="jxr_linenumber" name="L157" href="#L157">157</a> }
<a class="jxr_linenumber" name="L158" href="#L158">158</a>
<a class="jxr_linenumber" name="L159" href="#L159">159</a> <em class="jxr_javadoccomment">/** Registers a subcommand with the specified name. For example:</em>
<a class="jxr_linenumber" name="L160" href="#L160">160</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L161" href="#L161">161</a> <em class="jxr_javadoccomment"> * CommandLine commandLine = new CommandLine(new Git())</em>
<a class="jxr_linenumber" name="L162" href="#L162">162</a> <em class="jxr_javadoccomment"> * .addSubcommand("status", new GitStatus())</em>
<a class="jxr_linenumber" name="L163" href="#L163">163</a> <em class="jxr_javadoccomment"> * .addSubcommand("commit", new GitCommit();</em>
<a class="jxr_linenumber" name="L164" href="#L164">164</a> <em class="jxr_javadoccomment"> * .addSubcommand("add", new GitAdd())</em>
<a class="jxr_linenumber" name="L165" href="#L165">165</a> <em class="jxr_javadoccomment"> * .addSubcommand("branch", new GitBranch())</em>
<a class="jxr_linenumber" name="L166" href="#L166">166</a> <em class="jxr_javadoccomment"> * .addSubcommand("checkout", new GitCheckout())</em>
<a class="jxr_linenumber" name="L167" href="#L167">167</a> <em class="jxr_javadoccomment"> * //...</em>
<a class="jxr_linenumber" name="L168" href="#L168">168</a> <em class="jxr_javadoccomment"> * ;</em>
<a class="jxr_linenumber" name="L169" href="#L169">169</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L170" href="#L170">170</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L171" href="#L171">171</a> <em class="jxr_javadoccomment"> * &lt;p&gt;The specified object can be an annotated object or a</em>
<a class="jxr_linenumber" name="L172" href="#L172">172</a> <em class="jxr_javadoccomment"> * {@code CommandLine} instance with its own nested subcommands. For example:&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L173" href="#L173">173</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L174" href="#L174">174</a> <em class="jxr_javadoccomment"> * CommandLine commandLine = new CommandLine(new MainCommand())</em>
<a class="jxr_linenumber" name="L175" href="#L175">175</a> <em class="jxr_javadoccomment"> * .addSubcommand("cmd1", new ChildCommand1()) // subcommand</em>
<a class="jxr_linenumber" name="L176" href="#L176">176</a> <em class="jxr_javadoccomment"> * .addSubcommand("cmd2", new ChildCommand2())</em>
<a class="jxr_linenumber" name="L177" href="#L177">177</a> <em class="jxr_javadoccomment"> * .addSubcommand("cmd3", new CommandLine(new ChildCommand3()) // subcommand with nested sub-subcommands</em>
<a class="jxr_linenumber" name="L178" href="#L178">178</a> <em class="jxr_javadoccomment"> * .addSubcommand("cmd3sub1", new GrandChild3Command1())</em>
<a class="jxr_linenumber" name="L179" href="#L179">179</a> <em class="jxr_javadoccomment"> * .addSubcommand("cmd3sub2", new GrandChild3Command2())</em>
<a class="jxr_linenumber" name="L180" href="#L180">180</a> <em class="jxr_javadoccomment"> * .addSubcommand("cmd3sub3", new CommandLine(new GrandChild3Command3()) // deeper nesting</em>
<a class="jxr_linenumber" name="L181" href="#L181">181</a> <em class="jxr_javadoccomment"> * .addSubcommand("cmd3sub3sub1", new GreatGrandChild3Command3_1())</em>
<a class="jxr_linenumber" name="L182" href="#L182">182</a> <em class="jxr_javadoccomment"> * .addSubcommand("cmd3sub3sub2", new GreatGrandChild3Command3_2())</em>
<a class="jxr_linenumber" name="L183" href="#L183">183</a> <em class="jxr_javadoccomment"> * )</em>
<a class="jxr_linenumber" name="L184" href="#L184">184</a> <em class="jxr_javadoccomment"> * );</em>
<a class="jxr_linenumber" name="L185" href="#L185">185</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L186" href="#L186">186</a> <em class="jxr_javadoccomment"> * &lt;p&gt;The default type converters are available on all subcommands and nested sub-subcommands, but custom type</em>
<a class="jxr_linenumber" name="L187" href="#L187">187</a> <em class="jxr_javadoccomment"> * converters are registered only with the subcommand hierarchy as it existed when the custom type was registered.</em>
<a class="jxr_linenumber" name="L188" href="#L188">188</a> <em class="jxr_javadoccomment"> * To ensure a custom type converter is available to all subcommands, register the type converter last, after</em>
<a class="jxr_linenumber" name="L189" href="#L189">189</a> <em class="jxr_javadoccomment"> * adding subcommands.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L190" href="#L190">190</a> <em class="jxr_javadoccomment"> * &lt;p&gt;See also the {@link Command#subcommands()} annotation to register subcommands declaratively.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L191" href="#L191">191</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L192" href="#L192">192</a> <em class="jxr_javadoccomment"> * @param name the string to recognize on the command line as a subcommand</em>
<a class="jxr_linenumber" name="L193" href="#L193">193</a> <em class="jxr_javadoccomment"> * @param command the object to initialize with command line arguments following the subcommand name.</em>
<a class="jxr_linenumber" name="L194" href="#L194">194</a> <em class="jxr_javadoccomment"> * This may be a {@code CommandLine} instance with its own (nested) subcommands</em>
<a class="jxr_linenumber" name="L195" href="#L195">195</a> <em class="jxr_javadoccomment"> * @return this CommandLine object, to allow method chaining</em>
<a class="jxr_linenumber" name="L196" href="#L196">196</a> <em class="jxr_javadoccomment"> * @see #registerConverter(Class, ITypeConverter)</em>
<a class="jxr_linenumber" name="L197" href="#L197">197</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L198" href="#L198">198</a> <em class="jxr_javadoccomment"> * @see Command#subcommands()</em>
<a class="jxr_linenumber" name="L199" href="#L199">199</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L200" href="#L200">200</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> addSubcommand(<strong class="jxr_keyword">final</strong> String name, <strong class="jxr_keyword">final</strong> Object command) {
<a class="jxr_linenumber" name="L201" href="#L201">201</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine = toCommandLine(command);
<a class="jxr_linenumber" name="L202" href="#L202">202</a> commandLine.parent = <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L203" href="#L203">203</a> interpreter.commands.put(name, commandLine);
<a class="jxr_linenumber" name="L204" href="#L204">204</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L205" href="#L205">205</a> }
<a class="jxr_linenumber" name="L206" href="#L206">206</a> <em class="jxr_javadoccomment">/** Returns a map with the subcommands {@linkplain #addSubcommand(String, Object) registered} on this instance.</em>
<a class="jxr_linenumber" name="L207" href="#L207">207</a> <em class="jxr_javadoccomment"> * @return a map with the registered subcommands</em>
<a class="jxr_linenumber" name="L208" href="#L208">208</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L209" href="#L209">209</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L210" href="#L210">210</a> <strong class="jxr_keyword">public</strong> Map&lt;String, CommandLine&gt; getSubcommands() {
<a class="jxr_linenumber" name="L211" href="#L211">211</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> LinkedHashMap&lt;String, CommandLine&gt;(interpreter.commands);
<a class="jxr_linenumber" name="L212" href="#L212">212</a> }
<a class="jxr_linenumber" name="L213" href="#L213">213</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L214" href="#L214">214</a> <em class="jxr_javadoccomment"> * Returns the command that this is a subcommand of, or {@code null} if this is a top-level command.</em>
<a class="jxr_linenumber" name="L215" href="#L215">215</a> <em class="jxr_javadoccomment"> * @return the command that this is a subcommand of, or {@code null} if this is a top-level command</em>
<a class="jxr_linenumber" name="L216" href="#L216">216</a> <em class="jxr_javadoccomment"> * @see #addSubcommand(String, Object)</em>
<a class="jxr_linenumber" name="L217" href="#L217">217</a> <em class="jxr_javadoccomment"> * @see Command#subcommands()</em>
<a class="jxr_linenumber" name="L218" href="#L218">218</a> <em class="jxr_javadoccomment"> * @since 0.9.8</em>
<a class="jxr_linenumber" name="L219" href="#L219">219</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L220" href="#L220">220</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> getParent() {
<a class="jxr_linenumber" name="L221" href="#L221">221</a> <strong class="jxr_keyword">return</strong> parent;
<a class="jxr_linenumber" name="L222" href="#L222">222</a> }
<a class="jxr_linenumber" name="L223" href="#L223">223</a>
<a class="jxr_linenumber" name="L224" href="#L224">224</a> <em class="jxr_javadoccomment">/** Returns the annotated object that this {@code CommandLine} instance was constructed with.</em>
<a class="jxr_linenumber" name="L225" href="#L225">225</a> <em class="jxr_javadoccomment"> * @param &lt;T&gt; the type of the variable that the return value is being assigned to</em>
<a class="jxr_linenumber" name="L226" href="#L226">226</a> <em class="jxr_javadoccomment"> * @return the annotated object that this {@code CommandLine} instance was constructed with</em>
<a class="jxr_linenumber" name="L227" href="#L227">227</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L228" href="#L228">228</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L229" href="#L229">229</a> <strong class="jxr_keyword">public</strong> &lt;T&gt; T getCommand() {
<a class="jxr_linenumber" name="L230" href="#L230">230</a> <strong class="jxr_keyword">return</strong> (T) interpreter.command;
<a class="jxr_linenumber" name="L231" href="#L231">231</a> }
<a class="jxr_linenumber" name="L232" href="#L232">232</a>
<a class="jxr_linenumber" name="L233" href="#L233">233</a> <em class="jxr_javadoccomment">/** Returns {@code true} if an option annotated with {@link Option#usageHelp()} was specified on the command line.</em>
<a class="jxr_linenumber" name="L234" href="#L234">234</a> <em class="jxr_javadoccomment"> * @return whether the parser encountered an option annotated with {@link Option#usageHelp()}.</em>
<a class="jxr_linenumber" name="L235" href="#L235">235</a> <em class="jxr_javadoccomment"> * @since 0.9.8 */</em>
<a class="jxr_linenumber" name="L236" href="#L236">236</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> isUsageHelpRequested() { <strong class="jxr_keyword">return</strong> usageHelpRequested; }
<a class="jxr_linenumber" name="L237" href="#L237">237</a>
<a class="jxr_linenumber" name="L238" href="#L238">238</a> <em class="jxr_javadoccomment">/** Returns {@code true} if an option annotated with {@link Option#versionHelp()} was specified on the command line.</em>
<a class="jxr_linenumber" name="L239" href="#L239">239</a> <em class="jxr_javadoccomment"> * @return whether the parser encountered an option annotated with {@link Option#versionHelp()}.</em>
<a class="jxr_linenumber" name="L240" href="#L240">240</a> <em class="jxr_javadoccomment"> * @since 0.9.8 */</em>
<a class="jxr_linenumber" name="L241" href="#L241">241</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> isVersionHelpRequested() { <strong class="jxr_keyword">return</strong> versionHelpRequested; }
<a class="jxr_linenumber" name="L242" href="#L242">242</a>
<a class="jxr_linenumber" name="L243" href="#L243">243</a> <em class="jxr_javadoccomment">/** Returns whether options for single-value fields can be specified multiple times on the command line.</em>
<a class="jxr_linenumber" name="L244" href="#L244">244</a> <em class="jxr_javadoccomment"> * The default is {@code false} and a {@link OverwrittenOptionException} is thrown if this happens.</em>
<a class="jxr_linenumber" name="L245" href="#L245">245</a> <em class="jxr_javadoccomment"> * When {@code true}, the last specified value is retained.</em>
<a class="jxr_linenumber" name="L246" href="#L246">246</a> <em class="jxr_javadoccomment"> * @return {@code true} if options for single-value fields can be specified multiple times on the command line, {@code false} otherwise</em>
<a class="jxr_linenumber" name="L247" href="#L247">247</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L248" href="#L248">248</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L249" href="#L249">249</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> isOverwrittenOptionsAllowed() {
<a class="jxr_linenumber" name="L250" href="#L250">250</a> <strong class="jxr_keyword">return</strong> overwrittenOptionsAllowed;
<a class="jxr_linenumber" name="L251" href="#L251">251</a> }
<a class="jxr_linenumber" name="L252" href="#L252">252</a>
<a class="jxr_linenumber" name="L253" href="#L253">253</a> <em class="jxr_javadoccomment">/** Sets whether options for single-value fields can be specified multiple times on the command line without a {@link OverwrittenOptionException} being thrown.</em>
<a class="jxr_linenumber" name="L254" href="#L254">254</a> <em class="jxr_javadoccomment"> * &lt;p&gt;The specified setting will be registered with this {@code CommandLine} and the full hierarchy of its</em>
<a class="jxr_linenumber" name="L255" href="#L255">255</a> <em class="jxr_javadoccomment"> * subcommands and nested sub-subcommands &lt;em&gt;at the moment this method is called&lt;/em&gt;. Subcommands added</em>
<a class="jxr_linenumber" name="L256" href="#L256">256</a> <em class="jxr_javadoccomment"> * later will have the default setting. To ensure a setting is applied to all</em>
<a class="jxr_linenumber" name="L257" href="#L257">257</a> <em class="jxr_javadoccomment"> * subcommands, call the setter last, after adding subcommands.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L258" href="#L258">258</a> <em class="jxr_javadoccomment"> * @param newValue the new setting</em>
<a class="jxr_linenumber" name="L259" href="#L259">259</a> <em class="jxr_javadoccomment"> * @return this {@code CommandLine} object, to allow method chaining</em>
<a class="jxr_linenumber" name="L260" href="#L260">260</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L261" href="#L261">261</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L262" href="#L262">262</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> setOverwrittenOptionsAllowed(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> newValue) {
<a class="jxr_linenumber" name="L263" href="#L263">263</a> <strong class="jxr_keyword">this</strong>.overwrittenOptionsAllowed = newValue;
<a class="jxr_linenumber" name="L264" href="#L264">264</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> CommandLine command : interpreter.commands.values()) {
<a class="jxr_linenumber" name="L265" href="#L265">265</a> command.setOverwrittenOptionsAllowed(newValue);
<a class="jxr_linenumber" name="L266" href="#L266">266</a> }
<a class="jxr_linenumber" name="L267" href="#L267">267</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L268" href="#L268">268</a> }
<a class="jxr_linenumber" name="L269" href="#L269">269</a>
<a class="jxr_linenumber" name="L270" href="#L270">270</a> <em class="jxr_javadoccomment">/** Returns whether the end user may specify arguments on the command line that are not matched to any option or parameter fields.</em>
<a class="jxr_linenumber" name="L271" href="#L271">271</a> <em class="jxr_javadoccomment"> * The default is {@code false} and a {@link UnmatchedArgumentException} is thrown if this happens.</em>
<a class="jxr_linenumber" name="L272" href="#L272">272</a> <em class="jxr_javadoccomment"> * When {@code true}, the last unmatched arguments are available via the {@link #getUnmatchedArguments()} method.</em>
<a class="jxr_linenumber" name="L273" href="#L273">273</a> <em class="jxr_javadoccomment"> * @return {@code true} if the end use may specify unmatched arguments on the command line, {@code false} otherwise</em>
<a class="jxr_linenumber" name="L274" href="#L274">274</a> <em class="jxr_javadoccomment"> * @see #getUnmatchedArguments()</em>
<a class="jxr_linenumber" name="L275" href="#L275">275</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L276" href="#L276">276</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L277" href="#L277">277</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> isUnmatchedArgumentsAllowed() {
<a class="jxr_linenumber" name="L278" href="#L278">278</a> <strong class="jxr_keyword">return</strong> unmatchedArgumentsAllowed;
<a class="jxr_linenumber" name="L279" href="#L279">279</a> }
<a class="jxr_linenumber" name="L280" href="#L280">280</a>
<a class="jxr_linenumber" name="L281" href="#L281">281</a> <em class="jxr_javadoccomment">/** Sets whether the end user may specify unmatched arguments on the command line without a {@link UnmatchedArgumentException} being thrown.</em>
<a class="jxr_linenumber" name="L282" href="#L282">282</a> <em class="jxr_javadoccomment"> * &lt;p&gt;The specified setting will be registered with this {@code CommandLine} and the full hierarchy of its</em>
<a class="jxr_linenumber" name="L283" href="#L283">283</a> <em class="jxr_javadoccomment"> * subcommands and nested sub-subcommands &lt;em&gt;at the moment this method is called&lt;/em&gt;. Subcommands added</em>
<a class="jxr_linenumber" name="L284" href="#L284">284</a> <em class="jxr_javadoccomment"> * later will have the default setting. To ensure a setting is applied to all</em>
<a class="jxr_linenumber" name="L285" href="#L285">285</a> <em class="jxr_javadoccomment"> * subcommands, call the setter last, after adding subcommands.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L286" href="#L286">286</a> <em class="jxr_javadoccomment"> * @param newValue the new setting. When {@code true}, the last unmatched arguments are available via the {@link #getUnmatchedArguments()} method.</em>
<a class="jxr_linenumber" name="L287" href="#L287">287</a> <em class="jxr_javadoccomment"> * @return this {@code CommandLine} object, to allow method chaining</em>
<a class="jxr_linenumber" name="L288" href="#L288">288</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L289" href="#L289">289</a> <em class="jxr_javadoccomment"> * @see #getUnmatchedArguments()</em>
<a class="jxr_linenumber" name="L290" href="#L290">290</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L291" href="#L291">291</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> setUnmatchedArgumentsAllowed(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> newValue) {
<a class="jxr_linenumber" name="L292" href="#L292">292</a> <strong class="jxr_keyword">this</strong>.unmatchedArgumentsAllowed = newValue;
<a class="jxr_linenumber" name="L293" href="#L293">293</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> CommandLine command : interpreter.commands.values()) {
<a class="jxr_linenumber" name="L294" href="#L294">294</a> command.setUnmatchedArgumentsAllowed(newValue);
<a class="jxr_linenumber" name="L295" href="#L295">295</a> }
<a class="jxr_linenumber" name="L296" href="#L296">296</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L297" href="#L297">297</a> }
<a class="jxr_linenumber" name="L298" href="#L298">298</a>
<a class="jxr_linenumber" name="L299" href="#L299">299</a> <em class="jxr_javadoccomment">/** Returns the list of unmatched command line arguments, if any.</em>
<a class="jxr_linenumber" name="L300" href="#L300">300</a> <em class="jxr_javadoccomment"> * @return the list of unmatched command line arguments or an empty list</em>
<a class="jxr_linenumber" name="L301" href="#L301">301</a> <em class="jxr_javadoccomment"> * @see #isUnmatchedArgumentsAllowed()</em>
<a class="jxr_linenumber" name="L302" href="#L302">302</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L303" href="#L303">303</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L304" href="#L304">304</a> <strong class="jxr_keyword">public</strong> List&lt;String&gt; getUnmatchedArguments() {
<a class="jxr_linenumber" name="L305" href="#L305">305</a> <strong class="jxr_keyword">return</strong> unmatchedArguments;
<a class="jxr_linenumber" name="L306" href="#L306">306</a> }
<a class="jxr_linenumber" name="L307" href="#L307">307</a>
<a class="jxr_linenumber" name="L308" href="#L308">308</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L309" href="#L309">309</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L310" href="#L310">310</a> <em class="jxr_javadoccomment"> * Convenience method that initializes the specified annotated object from the specified command line arguments.</em>
<a class="jxr_linenumber" name="L311" href="#L311">311</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L312" href="#L312">312</a> <em class="jxr_javadoccomment"> * This is equivalent to</em>
<a class="jxr_linenumber" name="L313" href="#L313">313</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;pre&gt;</em>
<a class="jxr_linenumber" name="L314" href="#L314">314</a> <em class="jxr_javadoccomment"> * CommandLine cli = new CommandLine(command);</em>
<a class="jxr_linenumber" name="L315" href="#L315">315</a> <em class="jxr_javadoccomment"> * cli.parse(args);</em>
<a class="jxr_linenumber" name="L316" href="#L316">316</a> <em class="jxr_javadoccomment"> * return command;</em>
<a class="jxr_linenumber" name="L317" href="#L317">317</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L318" href="#L318">318</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L319" href="#L319">319</a> <em class="jxr_javadoccomment"> * @param command the object to initialize. This object contains fields annotated with</em>
<a class="jxr_linenumber" name="L320" href="#L320">320</a> <em class="jxr_javadoccomment"> * {@code @Option} or {@code @Parameters}.</em>
<a class="jxr_linenumber" name="L321" href="#L321">321</a> <em class="jxr_javadoccomment"> * @param args the command line arguments to parse</em>
<a class="jxr_linenumber" name="L322" href="#L322">322</a> <em class="jxr_javadoccomment"> * @param &lt;T&gt; the type of the annotated object</em>
<a class="jxr_linenumber" name="L323" href="#L323">323</a> <em class="jxr_javadoccomment"> * @return the specified annotated object</em>
<a class="jxr_linenumber" name="L324" href="#L324">324</a> <em class="jxr_javadoccomment"> * @throws InitializationException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L325" href="#L325">325</a> <em class="jxr_javadoccomment"> * @throws ParameterException if the specified command line arguments are invalid</em>
<a class="jxr_linenumber" name="L326" href="#L326">326</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L327" href="#L327">327</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L328" href="#L328">328</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> &lt;T&gt; T populateCommand(<strong class="jxr_keyword">final</strong> T command, <strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L329" href="#L329">329</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> cli = toCommandLine(command);
<a class="jxr_linenumber" name="L330" href="#L330">330</a> cli.parse(args);
<a class="jxr_linenumber" name="L331" href="#L331">331</a> <strong class="jxr_keyword">return</strong> command;
<a class="jxr_linenumber" name="L332" href="#L332">332</a> }
<a class="jxr_linenumber" name="L333" href="#L333">333</a>
<a class="jxr_linenumber" name="L334" href="#L334">334</a> <em class="jxr_javadoccomment">/** Parses the specified command line arguments and returns a list of {@code CommandLine} objects representing the</em>
<a class="jxr_linenumber" name="L335" href="#L335">335</a> <em class="jxr_javadoccomment"> * top-level command and any subcommands (if any) that were recognized and initialized during the parsing process.</em>
<a class="jxr_linenumber" name="L336" href="#L336">336</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L337" href="#L337">337</a> <em class="jxr_javadoccomment"> * If parsing succeeds, the first element in the returned list is always {@code this CommandLine} object. The</em>
<a class="jxr_linenumber" name="L338" href="#L338">338</a> <em class="jxr_javadoccomment"> * returned list may contain more elements if subcommands were {@linkplain #addSubcommand(String, Object) registered}</em>
<a class="jxr_linenumber" name="L339" href="#L339">339</a> <em class="jxr_javadoccomment"> * and these subcommands were initialized by matching command line arguments. If parsing fails, a</em>
<a class="jxr_linenumber" name="L340" href="#L340">340</a> <em class="jxr_javadoccomment"> * {@link ParameterException} is thrown.</em>
<a class="jxr_linenumber" name="L341" href="#L341">341</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L342" href="#L342">342</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L343" href="#L343">343</a> <em class="jxr_javadoccomment"> * @param args the command line arguments to parse</em>
<a class="jxr_linenumber" name="L344" href="#L344">344</a> <em class="jxr_javadoccomment"> * @return a list with the top-level command and any subcommands initialized by this method</em>
<a class="jxr_linenumber" name="L345" href="#L345">345</a> <em class="jxr_javadoccomment"> * @throws ParameterException if the specified command line arguments are invalid; use</em>
<a class="jxr_linenumber" name="L346" href="#L346">346</a> <em class="jxr_javadoccomment"> * {@link ParameterException#getCommandLine()} to get the command or subcommand whose user input was invalid</em>
<a class="jxr_linenumber" name="L347" href="#L347">347</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L348" href="#L348">348</a> <strong class="jxr_keyword">public</strong> List&lt;CommandLine&gt; parse(<strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L349" href="#L349">349</a> <strong class="jxr_keyword">return</strong> interpreter.parse(args);
<a class="jxr_linenumber" name="L350" href="#L350">350</a> }
<a class="jxr_linenumber" name="L351" href="#L351">351</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L352" href="#L352">352</a> <em class="jxr_javadoccomment"> * Represents a function that can process a List of {@code CommandLine} objects resulting from successfully</em>
<a class="jxr_linenumber" name="L353" href="#L353">353</a> <em class="jxr_javadoccomment"> * {@linkplain #parse(String...) parsing} the command line arguments. This is a</em>
<a class="jxr_linenumber" name="L354" href="#L354">354</a> <em class="jxr_javadoccomment"> * &lt;a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html"&gt;functional interface&lt;/a&gt;</em>
<a class="jxr_linenumber" name="L355" href="#L355">355</a> <em class="jxr_javadoccomment"> * whose functional method is {@link #handleParseResult(List, PrintStream, CommandLine.Help.Ansi)}.</em>
<a class="jxr_linenumber" name="L356" href="#L356">356</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L357" href="#L357">357</a> <em class="jxr_javadoccomment"> * Implementations of this functions can be passed to the {@link #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...) CommandLine::parseWithHandler}</em>
<a class="jxr_linenumber" name="L358" href="#L358">358</a> <em class="jxr_javadoccomment"> * methods to take some next step after the command line was successfully parsed.</em>
<a class="jxr_linenumber" name="L359" href="#L359">359</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L360" href="#L360">360</a> <em class="jxr_javadoccomment"> * @see RunFirst</em>
<a class="jxr_linenumber" name="L361" href="#L361">361</a> <em class="jxr_javadoccomment"> * @see RunLast</em>
<a class="jxr_linenumber" name="L362" href="#L362">362</a> <em class="jxr_javadoccomment"> * @see RunAll</em>
<a class="jxr_linenumber" name="L363" href="#L363">363</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L364" href="#L364">364</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParseResultHandler</a> {
<a class="jxr_linenumber" name="L365" href="#L365">365</a> <em class="jxr_javadoccomment">/** Processes a List of {@code CommandLine} objects resulting from successfully</em>
<a class="jxr_linenumber" name="L366" href="#L366">366</a> <em class="jxr_javadoccomment"> * {@linkplain #parse(String...) parsing} the command line arguments and optionally returns a list of results.</em>
<a class="jxr_linenumber" name="L367" href="#L367">367</a> <em class="jxr_javadoccomment"> * @param parsedCommands the {@code CommandLine} objects that resulted from successfully parsing the command line arguments</em>
<a class="jxr_linenumber" name="L368" href="#L368">368</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print help to if requested</em>
<a class="jxr_linenumber" name="L369" href="#L369">369</a> <em class="jxr_javadoccomment"> * @param ansi for printing help messages using ANSI styles and colors</em>
<a class="jxr_linenumber" name="L370" href="#L370">370</a> <em class="jxr_javadoccomment"> * @return a list of results, or an empty list if there are no results</em>
<a class="jxr_linenumber" name="L371" href="#L371">371</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if a problem occurred while processing the parse results; use</em>
<a class="jxr_linenumber" name="L372" href="#L372">372</a> <em class="jxr_javadoccomment"> * {@link ExecutionException#getCommandLine()} to get the command or subcommand where processing failed</em>
<a class="jxr_linenumber" name="L373" href="#L373">373</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L374" href="#L374">374</a> List&lt;Object&gt; handleParseResult(List&lt;CommandLine&gt; parsedCommands, PrintStream out, Help.Ansi ansi) <strong class="jxr_keyword">throws</strong> ExecutionException;
<a class="jxr_linenumber" name="L375" href="#L375">375</a> }
<a class="jxr_linenumber" name="L376" href="#L376">376</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L377" href="#L377">377</a> <em class="jxr_javadoccomment"> * Represents a function that can handle a {@code ParameterException} that occurred while</em>
<a class="jxr_linenumber" name="L378" href="#L378">378</a> <em class="jxr_javadoccomment"> * {@linkplain #parse(String...) parsing} the command line arguments. This is a</em>
<a class="jxr_linenumber" name="L379" href="#L379">379</a> <em class="jxr_javadoccomment"> * &lt;a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html"&gt;functional interface&lt;/a&gt;</em>
<a class="jxr_linenumber" name="L380" href="#L380">380</a> <em class="jxr_javadoccomment"> * whose functional method is {@link #handleException(CommandLine.ParameterException, PrintStream, CommandLine.Help.Ansi, String...)}.</em>
<a class="jxr_linenumber" name="L381" href="#L381">381</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L382" href="#L382">382</a> <em class="jxr_javadoccomment"> * Implementations of this functions can be passed to the {@link #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...) CommandLine::parseWithHandler}</em>
<a class="jxr_linenumber" name="L383" href="#L383">383</a> <em class="jxr_javadoccomment"> * methods to handle situations when the command line could not be parsed.</em>
<a class="jxr_linenumber" name="L384" href="#L384">384</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L385" href="#L385">385</a> <em class="jxr_javadoccomment"> * @see DefaultExceptionHandler</em>
<a class="jxr_linenumber" name="L386" href="#L386">386</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L387" href="#L387">387</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IExceptionHandler</a> {
<a class="jxr_linenumber" name="L388" href="#L388">388</a> <em class="jxr_javadoccomment">/** Handles a {@code ParameterException} that occurred while {@linkplain #parse(String...) parsing} the command</em>
<a class="jxr_linenumber" name="L389" href="#L389">389</a> <em class="jxr_javadoccomment"> * line arguments and optionally returns a list of results.</em>
<a class="jxr_linenumber" name="L390" href="#L390">390</a> <em class="jxr_javadoccomment"> * @param ex the ParameterException describing the problem that occurred while parsing the command line arguments,</em>
<a class="jxr_linenumber" name="L391" href="#L391">391</a> <em class="jxr_javadoccomment"> * and the CommandLine representing the command or subcommand whose input was invalid</em>
<a class="jxr_linenumber" name="L392" href="#L392">392</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print help to if requested</em>
<a class="jxr_linenumber" name="L393" href="#L393">393</a> <em class="jxr_javadoccomment"> * @param ansi for printing help messages using ANSI styles and colors</em>
<a class="jxr_linenumber" name="L394" href="#L394">394</a> <em class="jxr_javadoccomment"> * @param args the command line arguments that could not be parsed</em>
<a class="jxr_linenumber" name="L395" href="#L395">395</a> <em class="jxr_javadoccomment"> * @return a list of results, or an empty list if there are no results</em>
<a class="jxr_linenumber" name="L396" href="#L396">396</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L397" href="#L397">397</a> List&lt;Object&gt; handleException(<a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> ex, PrintStream out, Help.Ansi ansi, String... args);
<a class="jxr_linenumber" name="L398" href="#L398">398</a> }
<a class="jxr_linenumber" name="L399" href="#L399">399</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L400" href="#L400">400</a> <em class="jxr_javadoccomment"> * Default exception handler that prints the exception message to the specified {@code PrintStream}, followed by the</em>
<a class="jxr_linenumber" name="L401" href="#L401">401</a> <em class="jxr_javadoccomment"> * usage message for the command or subcommand whose input was invalid.</em>
<a class="jxr_linenumber" name="L402" href="#L402">402</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Implementation roughly looks like this:&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L403" href="#L403">403</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L404" href="#L404">404</a> <em class="jxr_javadoccomment"> * System.err.println(paramException.getMessage());</em>
<a class="jxr_linenumber" name="L405" href="#L405">405</a> <em class="jxr_javadoccomment"> * paramException.getCommandLine().usage(System.err);</em>
<a class="jxr_linenumber" name="L406" href="#L406">406</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L407" href="#L407">407</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L408" href="#L408">408</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultExceptionHandler</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IExceptionHandler</a> {
<a class="jxr_linenumber" name="L409" href="#L409">409</a> @Override
<a class="jxr_linenumber" name="L410" href="#L410">410</a> <strong class="jxr_keyword">public</strong> List&lt;Object&gt; handleException(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> ex, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi, <strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L411" href="#L411">411</a> out.println(ex.getMessage());
<a class="jxr_linenumber" name="L412" href="#L412">412</a> ex.getCommandLine().usage(out, ansi);
<a class="jxr_linenumber" name="L413" href="#L413">413</a> <strong class="jxr_keyword">return</strong> Collections.emptyList();
<a class="jxr_linenumber" name="L414" href="#L414">414</a> }
<a class="jxr_linenumber" name="L415" href="#L415">415</a> }
<a class="jxr_linenumber" name="L416" href="#L416">416</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L417" href="#L417">417</a> <em class="jxr_javadoccomment"> * Helper method that may be useful when processing the list of {@code CommandLine} objects that result from successfully</em>
<a class="jxr_linenumber" name="L418" href="#L418">418</a> <em class="jxr_javadoccomment"> * {@linkplain #parse(String...) parsing} command line arguments. This method prints out</em>
<a class="jxr_linenumber" name="L419" href="#L419">419</a> <em class="jxr_javadoccomment"> * {@linkplain #usage(PrintStream, Help.Ansi) usage help} if {@linkplain #isUsageHelpRequested() requested}</em>
<a class="jxr_linenumber" name="L420" href="#L420">420</a> <em class="jxr_javadoccomment"> * or {@linkplain #printVersionHelp(PrintStream, Help.Ansi) version help} if {@linkplain #isVersionHelpRequested() requested}</em>
<a class="jxr_linenumber" name="L421" href="#L421">421</a> <em class="jxr_javadoccomment"> * and returns {@code true}. Otherwise, if none of the specified {@code CommandLine} objects have help requested,</em>
<a class="jxr_linenumber" name="L422" href="#L422">422</a> <em class="jxr_javadoccomment"> * this method returns {@code false}.</em>
<a class="jxr_linenumber" name="L423" href="#L423">423</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L424" href="#L424">424</a> <em class="jxr_javadoccomment"> * Note that this method &lt;em&gt;only&lt;/em&gt; looks at the {@link Option#usageHelp() usageHelp} and</em>
<a class="jxr_linenumber" name="L425" href="#L425">425</a> <em class="jxr_javadoccomment"> * {@link Option#versionHelp() versionHelp} attributes. The {@link Option#help() help} attribute is ignored.</em>
<a class="jxr_linenumber" name="L426" href="#L426">426</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L427" href="#L427">427</a> <em class="jxr_javadoccomment"> * @param parsedCommands the list of {@code CommandLine} objects to check if help was requested</em>
<a class="jxr_linenumber" name="L428" href="#L428">428</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print help to if requested</em>
<a class="jxr_linenumber" name="L429" href="#L429">429</a> <em class="jxr_javadoccomment"> * @param ansi for printing help messages using ANSI styles and colors</em>
<a class="jxr_linenumber" name="L430" href="#L430">430</a> <em class="jxr_javadoccomment"> * @return {@code true} if help was printed, {@code false} otherwise</em>
<a class="jxr_linenumber" name="L431" href="#L431">431</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L432" href="#L432">432</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> printHelpIfRequested(<strong class="jxr_keyword">final</strong> List&lt;CommandLine&gt; parsedCommands, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi) {
<a class="jxr_linenumber" name="L433" href="#L433">433</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> CommandLine parsed : parsedCommands) {
<a class="jxr_linenumber" name="L434" href="#L434">434</a> <strong class="jxr_keyword">if</strong> (parsed.isUsageHelpRequested()) {
<a class="jxr_linenumber" name="L435" href="#L435">435</a> parsed.usage(out, ansi);
<a class="jxr_linenumber" name="L436" href="#L436">436</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L437" href="#L437">437</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (parsed.isVersionHelpRequested()) {
<a class="jxr_linenumber" name="L438" href="#L438">438</a> parsed.printVersionHelp(out, ansi);
<a class="jxr_linenumber" name="L439" href="#L439">439</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L440" href="#L440">440</a> }
<a class="jxr_linenumber" name="L441" href="#L441">441</a> }
<a class="jxr_linenumber" name="L442" href="#L442">442</a> <strong class="jxr_keyword">return</strong> false;
<a class="jxr_linenumber" name="L443" href="#L443">443</a> }
<a class="jxr_linenumber" name="L444" href="#L444">444</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> Object execute(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> parsed) {
<a class="jxr_linenumber" name="L445" href="#L445">445</a> <strong class="jxr_keyword">final</strong> Object command = parsed.getCommand();
<a class="jxr_linenumber" name="L446" href="#L446">446</a> <strong class="jxr_keyword">if</strong> (command instanceof Runnable) {
<a class="jxr_linenumber" name="L447" href="#L447">447</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L448" href="#L448">448</a> ((Runnable) command).run();
<a class="jxr_linenumber" name="L449" href="#L449">449</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L450" href="#L450">450</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ex) {
<a class="jxr_linenumber" name="L451" href="#L451">451</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ExecutionException</a>(parsed, <span class="jxr_string">"Error while running command ("</span> + command + <span class="jxr_string">")"</span>, ex);
<a class="jxr_linenumber" name="L452" href="#L452">452</a> }
<a class="jxr_linenumber" name="L453" href="#L453">453</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (command instanceof Callable) {
<a class="jxr_linenumber" name="L454" href="#L454">454</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L455" href="#L455">455</a> <strong class="jxr_keyword">return</strong> ((Callable&lt;Object&gt;) command).call();
<a class="jxr_linenumber" name="L456" href="#L456">456</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ex) {
<a class="jxr_linenumber" name="L457" href="#L457">457</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ExecutionException</a>(parsed, <span class="jxr_string">"Error while calling command ("</span> + command + <span class="jxr_string">")"</span>, ex);
<a class="jxr_linenumber" name="L458" href="#L458">458</a> }
<a class="jxr_linenumber" name="L459" href="#L459">459</a> }
<a class="jxr_linenumber" name="L460" href="#L460">460</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ExecutionException</a>(parsed, <span class="jxr_string">"Parsed command ("</span> + command + <span class="jxr_string">") is not Runnable or Callable"</span>);
<a class="jxr_linenumber" name="L461" href="#L461">461</a> }
<a class="jxr_linenumber" name="L462" href="#L462">462</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L463" href="#L463">463</a> <em class="jxr_javadoccomment"> * Command line parse result handler that prints help if requested, and otherwise executes the top-level</em>
<a class="jxr_linenumber" name="L464" href="#L464">464</a> <em class="jxr_javadoccomment"> * {@code Runnable} or {@code Callable} command.</em>
<a class="jxr_linenumber" name="L465" href="#L465">465</a> <em class="jxr_javadoccomment"> * For use in the {@link #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...) parseWithHandler} methods.</em>
<a class="jxr_linenumber" name="L466" href="#L466">466</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L467" href="#L467">467</a> <em class="jxr_javadoccomment"> * From picocli v2.0, {@code RunFirst} is used to implement the {@link #run(Runnable, PrintStream, Help.Ansi, String...) run}</em>
<a class="jxr_linenumber" name="L468" href="#L468">468</a> <em class="jxr_javadoccomment"> * and {@link #call(Callable, PrintStream, Help.Ansi, String...) call} convenience methods.</em>
<a class="jxr_linenumber" name="L469" href="#L469">469</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L470" href="#L470">470</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L471" href="#L471">471</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">RunFirst</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParseResultHandler</a> {
<a class="jxr_linenumber" name="L472" href="#L472">472</a> <em class="jxr_javadoccomment">/** Prints help if requested, and otherwise executes the top-level {@code Runnable} or {@code Callable} command.</em>
<a class="jxr_linenumber" name="L473" href="#L473">473</a> <em class="jxr_javadoccomment"> * If the top-level command does not implement either {@code Runnable} or {@code Callable}, a {@code ExecutionException}</em>
<a class="jxr_linenumber" name="L474" href="#L474">474</a> <em class="jxr_javadoccomment"> * is thrown detailing the problem and capturing the offending {@code CommandLine} object.</em>
<a class="jxr_linenumber" name="L475" href="#L475">475</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L476" href="#L476">476</a> <em class="jxr_javadoccomment"> * @param parsedCommands the {@code CommandLine} objects that resulted from successfully parsing the command line arguments</em>
<a class="jxr_linenumber" name="L477" href="#L477">477</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print help to if requested</em>
<a class="jxr_linenumber" name="L478" href="#L478">478</a> <em class="jxr_javadoccomment"> * @param ansi for printing help messages using ANSI styles and colors</em>
<a class="jxr_linenumber" name="L479" href="#L479">479</a> <em class="jxr_javadoccomment"> * @return an empty list if help was requested, or a list containing a single element: the result of calling the</em>
<a class="jxr_linenumber" name="L480" href="#L480">480</a> <em class="jxr_javadoccomment"> * {@code Callable}, or a {@code null} element if the top-level command was a {@code Runnable}</em>
<a class="jxr_linenumber" name="L481" href="#L481">481</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if a problem occurred while processing the parse results; use</em>
<a class="jxr_linenumber" name="L482" href="#L482">482</a> <em class="jxr_javadoccomment"> * {@link ExecutionException#getCommandLine()} to get the command or subcommand where processing failed</em>
<a class="jxr_linenumber" name="L483" href="#L483">483</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L484" href="#L484">484</a> @Override
<a class="jxr_linenumber" name="L485" href="#L485">485</a> <strong class="jxr_keyword">public</strong> List&lt;Object&gt; handleParseResult(<strong class="jxr_keyword">final</strong> List&lt;CommandLine&gt; parsedCommands, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi) {
<a class="jxr_linenumber" name="L486" href="#L486">486</a> <strong class="jxr_keyword">if</strong> (printHelpIfRequested(parsedCommands, out, ansi)) { <strong class="jxr_keyword">return</strong> Collections.emptyList(); }
<a class="jxr_linenumber" name="L487" href="#L487">487</a> <strong class="jxr_keyword">return</strong> Arrays.asList(execute(parsedCommands.get(0)));
<a class="jxr_linenumber" name="L488" href="#L488">488</a> }
<a class="jxr_linenumber" name="L489" href="#L489">489</a> }
<a class="jxr_linenumber" name="L490" href="#L490">490</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L491" href="#L491">491</a> <em class="jxr_javadoccomment"> * Command line parse result handler that prints help if requested, and otherwise executes the most specific</em>
<a class="jxr_linenumber" name="L492" href="#L492">492</a> <em class="jxr_javadoccomment"> * {@code Runnable} or {@code Callable} subcommand.</em>
<a class="jxr_linenumber" name="L493" href="#L493">493</a> <em class="jxr_javadoccomment"> * For use in the {@link #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...) parseWithHandler} methods.</em>
<a class="jxr_linenumber" name="L494" href="#L494">494</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L495" href="#L495">495</a> <em class="jxr_javadoccomment"> * Something like this:&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L496" href="#L496">496</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L497" href="#L497">497</a> <em class="jxr_javadoccomment"> * // RunLast implementation: print help if requested, otherwise execute the most specific subcommand</em>
<a class="jxr_linenumber" name="L498" href="#L498">498</a> <em class="jxr_javadoccomment"> * if (CommandLine.printHelpIfRequested(parsedCommands, System.err, Help.Ansi.AUTO)) {</em>
<a class="jxr_linenumber" name="L499" href="#L499">499</a> <em class="jxr_javadoccomment"> * return emptyList();</em>
<a class="jxr_linenumber" name="L500" href="#L500">500</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L501" href="#L501">501</a> <em class="jxr_javadoccomment"> * CommandLine last = parsedCommands.get(parsedCommands.size() - 1);</em>
<a class="jxr_linenumber" name="L502" href="#L502">502</a> <em class="jxr_javadoccomment"> * Object command = last.getCommand();</em>
<a class="jxr_linenumber" name="L503" href="#L503">503</a> <em class="jxr_javadoccomment"> * if (command instanceof Runnable) {</em>
<a class="jxr_linenumber" name="L504" href="#L504">504</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L505" href="#L505">505</a> <em class="jxr_javadoccomment"> * ((Runnable) command).run();</em>
<a class="jxr_linenumber" name="L506" href="#L506">506</a> <em class="jxr_javadoccomment"> * } catch (Exception ex) {</em>
<a class="jxr_linenumber" name="L507" href="#L507">507</a> <em class="jxr_javadoccomment"> * throw new ExecutionException(last, "Error in runnable " + command, ex);</em>
<a class="jxr_linenumber" name="L508" href="#L508">508</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L509" href="#L509">509</a> <em class="jxr_javadoccomment"> * } else if (command instanceof Callable) {</em>
<a class="jxr_linenumber" name="L510" href="#L510">510</a> <em class="jxr_javadoccomment"> * Object result;</em>
<a class="jxr_linenumber" name="L511" href="#L511">511</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L512" href="#L512">512</a> <em class="jxr_javadoccomment"> * result = ((Callable) command).call();</em>
<a class="jxr_linenumber" name="L513" href="#L513">513</a> <em class="jxr_javadoccomment"> * } catch (Exception ex) {</em>
<a class="jxr_linenumber" name="L514" href="#L514">514</a> <em class="jxr_javadoccomment"> * throw new ExecutionException(last, "Error in callable " + command, ex);</em>
<a class="jxr_linenumber" name="L515" href="#L515">515</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L516" href="#L516">516</a> <em class="jxr_javadoccomment"> * // ...do something with result</em>
<a class="jxr_linenumber" name="L517" href="#L517">517</a> <em class="jxr_javadoccomment"> * } else {</em>
<a class="jxr_linenumber" name="L518" href="#L518">518</a> <em class="jxr_javadoccomment"> * throw new ExecutionException(last, "Parsed command (" + command + ") is not Runnable or Callable");</em>
<a class="jxr_linenumber" name="L519" href="#L519">519</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L520" href="#L520">520</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L521" href="#L521">521</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L522" href="#L522">522</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">RunLast</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParseResultHandler</a> {
<a class="jxr_linenumber" name="L523" href="#L523">523</a> <em class="jxr_javadoccomment">/** Prints help if requested, and otherwise executes the most specific {@code Runnable} or {@code Callable} subcommand.</em>
<a class="jxr_linenumber" name="L524" href="#L524">524</a> <em class="jxr_javadoccomment"> * If the last (sub)command does not implement either {@code Runnable} or {@code Callable}, a {@code ExecutionException}</em>
<a class="jxr_linenumber" name="L525" href="#L525">525</a> <em class="jxr_javadoccomment"> * is thrown detailing the problem and capturing the offending {@code CommandLine} object.</em>
<a class="jxr_linenumber" name="L526" href="#L526">526</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L527" href="#L527">527</a> <em class="jxr_javadoccomment"> * @param parsedCommands the {@code CommandLine} objects that resulted from successfully parsing the command line arguments</em>
<a class="jxr_linenumber" name="L528" href="#L528">528</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print help to if requested</em>
<a class="jxr_linenumber" name="L529" href="#L529">529</a> <em class="jxr_javadoccomment"> * @param ansi for printing help messages using ANSI styles and colors</em>
<a class="jxr_linenumber" name="L530" href="#L530">530</a> <em class="jxr_javadoccomment"> * @return an empty list if help was requested, or a list containing a single element: the result of calling the</em>
<a class="jxr_linenumber" name="L531" href="#L531">531</a> <em class="jxr_javadoccomment"> * {@code Callable}, or a {@code null} element if the last (sub)command was a {@code Runnable}</em>
<a class="jxr_linenumber" name="L532" href="#L532">532</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if a problem occurred while processing the parse results; use</em>
<a class="jxr_linenumber" name="L533" href="#L533">533</a> <em class="jxr_javadoccomment"> * {@link ExecutionException#getCommandLine()} to get the command or subcommand where processing failed</em>
<a class="jxr_linenumber" name="L534" href="#L534">534</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L535" href="#L535">535</a> @Override
<a class="jxr_linenumber" name="L536" href="#L536">536</a> <strong class="jxr_keyword">public</strong> List&lt;Object&gt; handleParseResult(<strong class="jxr_keyword">final</strong> List&lt;CommandLine&gt; parsedCommands, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi) {
<a class="jxr_linenumber" name="L537" href="#L537">537</a> <strong class="jxr_keyword">if</strong> (printHelpIfRequested(parsedCommands, out, ansi)) { <strong class="jxr_keyword">return</strong> Collections.emptyList(); }
<a class="jxr_linenumber" name="L538" href="#L538">538</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> last = parsedCommands.get(parsedCommands.size() - 1);
<a class="jxr_linenumber" name="L539" href="#L539">539</a> <strong class="jxr_keyword">return</strong> Arrays.asList(execute(last));
<a class="jxr_linenumber" name="L540" href="#L540">540</a> }
<a class="jxr_linenumber" name="L541" href="#L541">541</a> }
<a class="jxr_linenumber" name="L542" href="#L542">542</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L543" href="#L543">543</a> <em class="jxr_javadoccomment"> * Command line parse result handler that prints help if requested, and otherwise executes the top-level command and</em>
<a class="jxr_linenumber" name="L544" href="#L544">544</a> <em class="jxr_javadoccomment"> * all subcommands as {@code Runnable} or {@code Callable}.</em>
<a class="jxr_linenumber" name="L545" href="#L545">545</a> <em class="jxr_javadoccomment"> * For use in the {@link #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...) parseWithHandler} methods.</em>
<a class="jxr_linenumber" name="L546" href="#L546">546</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L547" href="#L547">547</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">RunAll</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParseResultHandler</a> {
<a class="jxr_linenumber" name="L548" href="#L548">548</a> <em class="jxr_javadoccomment">/** Prints help if requested, and otherwise executes the top-level command and all subcommands as {@code Runnable}</em>
<a class="jxr_linenumber" name="L549" href="#L549">549</a> <em class="jxr_javadoccomment"> * or {@code Callable}. If any of the {@code CommandLine} commands does not implement either</em>
<a class="jxr_linenumber" name="L550" href="#L550">550</a> <em class="jxr_javadoccomment"> * {@code Runnable} or {@code Callable}, a {@code ExecutionException}</em>
<a class="jxr_linenumber" name="L551" href="#L551">551</a> <em class="jxr_javadoccomment"> * is thrown detailing the problem and capturing the offending {@code CommandLine} object.</em>
<a class="jxr_linenumber" name="L552" href="#L552">552</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L553" href="#L553">553</a> <em class="jxr_javadoccomment"> * @param parsedCommands the {@code CommandLine} objects that resulted from successfully parsing the command line arguments</em>
<a class="jxr_linenumber" name="L554" href="#L554">554</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print help to if requested</em>
<a class="jxr_linenumber" name="L555" href="#L555">555</a> <em class="jxr_javadoccomment"> * @param ansi for printing help messages using ANSI styles and colors</em>
<a class="jxr_linenumber" name="L556" href="#L556">556</a> <em class="jxr_javadoccomment"> * @return an empty list if help was requested, or a list containing the result of executing all commands:</em>
<a class="jxr_linenumber" name="L557" href="#L557">557</a> <em class="jxr_javadoccomment"> * the return values from calling the {@code Callable} commands, {@code null} elements for commands that implement {@code Runnable}</em>
<a class="jxr_linenumber" name="L558" href="#L558">558</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if a problem occurred while processing the parse results; use</em>
<a class="jxr_linenumber" name="L559" href="#L559">559</a> <em class="jxr_javadoccomment"> * {@link ExecutionException#getCommandLine()} to get the command or subcommand where processing failed</em>
<a class="jxr_linenumber" name="L560" href="#L560">560</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L561" href="#L561">561</a> @Override
<a class="jxr_linenumber" name="L562" href="#L562">562</a> <strong class="jxr_keyword">public</strong> List&lt;Object&gt; handleParseResult(<strong class="jxr_keyword">final</strong> List&lt;CommandLine&gt; parsedCommands, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi) {
<a class="jxr_linenumber" name="L563" href="#L563">563</a> <strong class="jxr_keyword">if</strong> (printHelpIfRequested(parsedCommands, out, ansi)) {
<a class="jxr_linenumber" name="L564" href="#L564">564</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L565" href="#L565">565</a> }
<a class="jxr_linenumber" name="L566" href="#L566">566</a> <strong class="jxr_keyword">final</strong> List&lt;Object&gt; result = <strong class="jxr_keyword">new</strong> ArrayList&lt;Object&gt;();
<a class="jxr_linenumber" name="L567" href="#L567">567</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> CommandLine parsed : parsedCommands) {
<a class="jxr_linenumber" name="L568" href="#L568">568</a> result.add(execute(parsed));
<a class="jxr_linenumber" name="L569" href="#L569">569</a> }
<a class="jxr_linenumber" name="L570" href="#L570">570</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L571" href="#L571">571</a> }
<a class="jxr_linenumber" name="L572" href="#L572">572</a> }
<a class="jxr_linenumber" name="L573" href="#L573">573</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L574" href="#L574">574</a> <em class="jxr_javadoccomment"> * Returns the result of calling {@link #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...)}</em>
<a class="jxr_linenumber" name="L575" href="#L575">575</a> <em class="jxr_javadoccomment"> * with {@code Help.Ansi.AUTO} and a new {@link DefaultExceptionHandler} in addition to the specified parse result handler,</em>
<a class="jxr_linenumber" name="L576" href="#L576">576</a> <em class="jxr_javadoccomment"> * {@code PrintStream}, and the specified command line arguments.</em>
<a class="jxr_linenumber" name="L577" href="#L577">577</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L578" href="#L578">578</a> <em class="jxr_javadoccomment"> * This is a convenience method intended to offer the same ease of use as the {@link #run(Runnable, PrintStream, Help.Ansi, String...) run}</em>
<a class="jxr_linenumber" name="L579" href="#L579">579</a> <em class="jxr_javadoccomment"> * and {@link #call(Callable, PrintStream, Help.Ansi, String...) call} methods, but with more flexibility and better</em>
<a class="jxr_linenumber" name="L580" href="#L580">580</a> <em class="jxr_javadoccomment"> * support for nested subcommands.</em>
<a class="jxr_linenumber" name="L581" href="#L581">581</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L582" href="#L582">582</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Calling this method roughly expands to:&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L583" href="#L583">583</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L584" href="#L584">584</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L585" href="#L585">585</a> <em class="jxr_javadoccomment"> * List&amp;lt;CommandLine&amp;gt; parsedCommands = parse(args);</em>
<a class="jxr_linenumber" name="L586" href="#L586">586</a> <em class="jxr_javadoccomment"> * return parseResultsHandler.handleParseResult(parsedCommands, out, Help.Ansi.AUTO);</em>
<a class="jxr_linenumber" name="L587" href="#L587">587</a> <em class="jxr_javadoccomment"> * } catch (ParameterException ex) {</em>
<a class="jxr_linenumber" name="L588" href="#L588">588</a> <em class="jxr_javadoccomment"> * return new DefaultExceptionHandler().handleException(ex, out, ansi, args);</em>
<a class="jxr_linenumber" name="L589" href="#L589">589</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L590" href="#L590">590</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L591" href="#L591">591</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L592" href="#L592">592</a> <em class="jxr_javadoccomment"> * Picocli provides some default handlers that allow you to accomplish some common tasks with very little code.</em>
<a class="jxr_linenumber" name="L593" href="#L593">593</a> <em class="jxr_javadoccomment"> * The following handlers are available:&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L594" href="#L594">594</a> <em class="jxr_javadoccomment"> * &lt;ul&gt;</em>
<a class="jxr_linenumber" name="L595" href="#L595">595</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@link RunLast} handler prints help if requested, and otherwise gets the last specified command or subcommand</em>
<a class="jxr_linenumber" name="L596" href="#L596">596</a> <em class="jxr_javadoccomment"> * and tries to execute it as a {@code Runnable} or {@code Callable}.&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L597" href="#L597">597</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@link RunFirst} handler prints help if requested, and otherwise executes the top-level command as a {@code Runnable} or {@code Callable}.&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L598" href="#L598">598</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@link RunAll} handler prints help if requested, and otherwise executes all recognized commands and subcommands as {@code Runnable} or {@code Callable} tasks.&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L599" href="#L599">599</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@link DefaultExceptionHandler} prints the error message followed by usage help&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L600" href="#L600">600</a> <em class="jxr_javadoccomment"> * &lt;/ul&gt;</em>
<a class="jxr_linenumber" name="L601" href="#L601">601</a> <em class="jxr_javadoccomment"> * @param handler the function that will process the result of successfully parsing the command line arguments</em>
<a class="jxr_linenumber" name="L602" href="#L602">602</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print help to if requested</em>
<a class="jxr_linenumber" name="L603" href="#L603">603</a> <em class="jxr_javadoccomment"> * @param args the command line arguments</em>
<a class="jxr_linenumber" name="L604" href="#L604">604</a> <em class="jxr_javadoccomment"> * @return a list of results, or an empty list if there are no results</em>
<a class="jxr_linenumber" name="L605" href="#L605">605</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if the command line arguments were parsed successfully but a problem occurred while processing the</em>
<a class="jxr_linenumber" name="L606" href="#L606">606</a> <em class="jxr_javadoccomment"> * parse results; use {@link ExecutionException#getCommandLine()} to get the command or subcommand where processing failed</em>
<a class="jxr_linenumber" name="L607" href="#L607">607</a> <em class="jxr_javadoccomment"> * @see RunLast</em>
<a class="jxr_linenumber" name="L608" href="#L608">608</a> <em class="jxr_javadoccomment"> * @see RunAll</em>
<a class="jxr_linenumber" name="L609" href="#L609">609</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L610" href="#L610">610</a> <strong class="jxr_keyword">public</strong> List&lt;Object&gt; parseWithHandler(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParseResultHandler</a> handler, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L611" href="#L611">611</a> <strong class="jxr_keyword">return</strong> parseWithHandlers(handler, out, Help.Ansi.AUTO, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultExceptionHandler</a>(), args);
<a class="jxr_linenumber" name="L612" href="#L612">612</a> }
<a class="jxr_linenumber" name="L613" href="#L613">613</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L614" href="#L614">614</a> <em class="jxr_javadoccomment"> * Tries to {@linkplain #parse(String...) parse} the specified command line arguments, and if successful, delegates</em>
<a class="jxr_linenumber" name="L615" href="#L615">615</a> <em class="jxr_javadoccomment"> * the processing of the resulting list of {@code CommandLine} objects to the specified {@linkplain IParseResultHandler handler}.</em>
<a class="jxr_linenumber" name="L616" href="#L616">616</a> <em class="jxr_javadoccomment"> * If the command line arguments were invalid, the {@code ParameterException} thrown from the {@code parse} method</em>
<a class="jxr_linenumber" name="L617" href="#L617">617</a> <em class="jxr_javadoccomment"> * is caught and passed to the specified {@link IExceptionHandler}.</em>
<a class="jxr_linenumber" name="L618" href="#L618">618</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L619" href="#L619">619</a> <em class="jxr_javadoccomment"> * This is a convenience method intended to offer the same ease of use as the {@link #run(Runnable, PrintStream, Help.Ansi, String...) run}</em>
<a class="jxr_linenumber" name="L620" href="#L620">620</a> <em class="jxr_javadoccomment"> * and {@link #call(Callable, PrintStream, Help.Ansi, String...) call} methods, but with more flexibility and better</em>
<a class="jxr_linenumber" name="L621" href="#L621">621</a> <em class="jxr_javadoccomment"> * support for nested subcommands.</em>
<a class="jxr_linenumber" name="L622" href="#L622">622</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L623" href="#L623">623</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Calling this method roughly expands to:&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L624" href="#L624">624</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L625" href="#L625">625</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L626" href="#L626">626</a> <em class="jxr_javadoccomment"> * List&amp;lt;CommandLine&amp;gt; parsedCommands = parse(args);</em>
<a class="jxr_linenumber" name="L627" href="#L627">627</a> <em class="jxr_javadoccomment"> * return parseResultsHandler.handleParseResult(parsedCommands, out, ansi);</em>
<a class="jxr_linenumber" name="L628" href="#L628">628</a> <em class="jxr_javadoccomment"> * } catch (ParameterException ex) {</em>
<a class="jxr_linenumber" name="L629" href="#L629">629</a> <em class="jxr_javadoccomment"> * return new exceptionHandler.handleException(ex, out, ansi, args);</em>
<a class="jxr_linenumber" name="L630" href="#L630">630</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L631" href="#L631">631</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L632" href="#L632">632</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L633" href="#L633">633</a> <em class="jxr_javadoccomment"> * Picocli provides some default handlers that allow you to accomplish some common tasks with very little code.</em>
<a class="jxr_linenumber" name="L634" href="#L634">634</a> <em class="jxr_javadoccomment"> * The following handlers are available:&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L635" href="#L635">635</a> <em class="jxr_javadoccomment"> * &lt;ul&gt;</em>
<a class="jxr_linenumber" name="L636" href="#L636">636</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@link RunLast} handler prints help if requested, and otherwise gets the last specified command or subcommand</em>
<a class="jxr_linenumber" name="L637" href="#L637">637</a> <em class="jxr_javadoccomment"> * and tries to execute it as a {@code Runnable} or {@code Callable}.&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L638" href="#L638">638</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@link RunFirst} handler prints help if requested, and otherwise executes the top-level command as a {@code Runnable} or {@code Callable}.&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L639" href="#L639">639</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@link RunAll} handler prints help if requested, and otherwise executes all recognized commands and subcommands as {@code Runnable} or {@code Callable} tasks.&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L640" href="#L640">640</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@link DefaultExceptionHandler} prints the error message followed by usage help&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L641" href="#L641">641</a> <em class="jxr_javadoccomment"> * &lt;/ul&gt;</em>
<a class="jxr_linenumber" name="L642" href="#L642">642</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L643" href="#L643">643</a> <em class="jxr_javadoccomment"> * @param handler the function that will process the result of successfully parsing the command line arguments</em>
<a class="jxr_linenumber" name="L644" href="#L644">644</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print help to if requested</em>
<a class="jxr_linenumber" name="L645" href="#L645">645</a> <em class="jxr_javadoccomment"> * @param ansi for printing help messages using ANSI styles and colors</em>
<a class="jxr_linenumber" name="L646" href="#L646">646</a> <em class="jxr_javadoccomment"> * @param exceptionHandler the function that can handle the {@code ParameterException} thrown when the command line arguments are invalid</em>
<a class="jxr_linenumber" name="L647" href="#L647">647</a> <em class="jxr_javadoccomment"> * @param args the command line arguments</em>
<a class="jxr_linenumber" name="L648" href="#L648">648</a> <em class="jxr_javadoccomment"> * @return a list of results produced by the {@code IParseResultHandler} or the {@code IExceptionHandler}, or an empty list if there are no results</em>
<a class="jxr_linenumber" name="L649" href="#L649">649</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if the command line arguments were parsed successfully but a problem occurred while processing the parse</em>
<a class="jxr_linenumber" name="L650" href="#L650">650</a> <em class="jxr_javadoccomment"> * result {@code CommandLine} objects; use {@link ExecutionException#getCommandLine()} to get the command or subcommand where processing failed</em>
<a class="jxr_linenumber" name="L651" href="#L651">651</a> <em class="jxr_javadoccomment"> * @see RunLast</em>
<a class="jxr_linenumber" name="L652" href="#L652">652</a> <em class="jxr_javadoccomment"> * @see RunAll</em>
<a class="jxr_linenumber" name="L653" href="#L653">653</a> <em class="jxr_javadoccomment"> * @see DefaultExceptionHandler</em>
<a class="jxr_linenumber" name="L654" href="#L654">654</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L655" href="#L655">655</a> <strong class="jxr_keyword">public</strong> List&lt;Object&gt; parseWithHandlers(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParseResultHandler</a> handler, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IExceptionHandler</a> exceptionHandler, <strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L656" href="#L656">656</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L657" href="#L657">657</a> <strong class="jxr_keyword">final</strong> List&lt;CommandLine&gt; result = parse(args);
<a class="jxr_linenumber" name="L658" href="#L658">658</a> <strong class="jxr_keyword">return</strong> handler.handleParseResult(result, out, ansi);
<a class="jxr_linenumber" name="L659" href="#L659">659</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> ParameterException ex) {
<a class="jxr_linenumber" name="L660" href="#L660">660</a> <strong class="jxr_keyword">return</strong> exceptionHandler.handleException(ex, out, ansi, args);
<a class="jxr_linenumber" name="L661" href="#L661">661</a> }
<a class="jxr_linenumber" name="L662" href="#L662">662</a> }
<a class="jxr_linenumber" name="L663" href="#L663">663</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L664" href="#L664">664</a> <em class="jxr_javadoccomment"> * Equivalent to {@code new CommandLine(command).usage(out)}. See {@link #usage(PrintStream)} for details.</em>
<a class="jxr_linenumber" name="L665" href="#L665">665</a> <em class="jxr_javadoccomment"> * @param command the object annotated with {@link Command}, {@link Option} and {@link Parameters}</em>
<a class="jxr_linenumber" name="L666" href="#L666">666</a> <em class="jxr_javadoccomment"> * @param out the print stream to print the help message to</em>
<a class="jxr_linenumber" name="L667" href="#L667">667</a> <em class="jxr_javadoccomment"> * @throws IllegalArgumentException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L668" href="#L668">668</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L669" href="#L669">669</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> usage(<strong class="jxr_keyword">final</strong> Object command, <strong class="jxr_keyword">final</strong> PrintStream out) {
<a class="jxr_linenumber" name="L670" href="#L670">670</a> toCommandLine(command).usage(out);
<a class="jxr_linenumber" name="L671" href="#L671">671</a> }
<a class="jxr_linenumber" name="L672" href="#L672">672</a>
<a class="jxr_linenumber" name="L673" href="#L673">673</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L674" href="#L674">674</a> <em class="jxr_javadoccomment"> * Equivalent to {@code new CommandLine(command).usage(out, ansi)}.</em>
<a class="jxr_linenumber" name="L675" href="#L675">675</a> <em class="jxr_javadoccomment"> * See {@link #usage(PrintStream, Help.Ansi)} for details.</em>
<a class="jxr_linenumber" name="L676" href="#L676">676</a> <em class="jxr_javadoccomment"> * @param command the object annotated with {@link Command}, {@link Option} and {@link Parameters}</em>
<a class="jxr_linenumber" name="L677" href="#L677">677</a> <em class="jxr_javadoccomment"> * @param out the print stream to print the help message to</em>
<a class="jxr_linenumber" name="L678" href="#L678">678</a> <em class="jxr_javadoccomment"> * @param ansi whether the usage message should contain ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L679" href="#L679">679</a> <em class="jxr_javadoccomment"> * @throws IllegalArgumentException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L680" href="#L680">680</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L681" href="#L681">681</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> usage(<strong class="jxr_keyword">final</strong> Object command, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi) {
<a class="jxr_linenumber" name="L682" href="#L682">682</a> toCommandLine(command).usage(out, ansi);
<a class="jxr_linenumber" name="L683" href="#L683">683</a> }
<a class="jxr_linenumber" name="L684" href="#L684">684</a>
<a class="jxr_linenumber" name="L685" href="#L685">685</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L686" href="#L686">686</a> <em class="jxr_javadoccomment"> * Equivalent to {@code new CommandLine(command).usage(out, colorScheme)}.</em>
<a class="jxr_linenumber" name="L687" href="#L687">687</a> <em class="jxr_javadoccomment"> * See {@link #usage(PrintStream, Help.ColorScheme)} for details.</em>
<a class="jxr_linenumber" name="L688" href="#L688">688</a> <em class="jxr_javadoccomment"> * @param command the object annotated with {@link Command}, {@link Option} and {@link Parameters}</em>
<a class="jxr_linenumber" name="L689" href="#L689">689</a> <em class="jxr_javadoccomment"> * @param out the print stream to print the help message to</em>
<a class="jxr_linenumber" name="L690" href="#L690">690</a> <em class="jxr_javadoccomment"> * @param colorScheme the {@code ColorScheme} defining the styles for options, parameters and commands when ANSI is enabled</em>
<a class="jxr_linenumber" name="L691" href="#L691">691</a> <em class="jxr_javadoccomment"> * @throws IllegalArgumentException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L692" href="#L692">692</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L693" href="#L693">693</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> usage(<strong class="jxr_keyword">final</strong> Object command, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.ColorScheme colorScheme) {
<a class="jxr_linenumber" name="L694" href="#L694">694</a> toCommandLine(command).usage(out, colorScheme);
<a class="jxr_linenumber" name="L695" href="#L695">695</a> }
<a class="jxr_linenumber" name="L696" href="#L696">696</a>
<a class="jxr_linenumber" name="L697" href="#L697">697</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L698" href="#L698">698</a> <em class="jxr_javadoccomment"> * Delegates to {@link #usage(PrintStream, Help.Ansi)} with the {@linkplain Help.Ansi#AUTO platform default}.</em>
<a class="jxr_linenumber" name="L699" href="#L699">699</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L700" href="#L700">700</a> <em class="jxr_javadoccomment"> * @see #usage(PrintStream, Help.ColorScheme)</em>
<a class="jxr_linenumber" name="L701" href="#L701">701</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L702" href="#L702">702</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> usage(<strong class="jxr_keyword">final</strong> PrintStream out) {
<a class="jxr_linenumber" name="L703" href="#L703">703</a> usage(out, Help.Ansi.AUTO);
<a class="jxr_linenumber" name="L704" href="#L704">704</a> }
<a class="jxr_linenumber" name="L705" href="#L705">705</a>
<a class="jxr_linenumber" name="L706" href="#L706">706</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L707" href="#L707">707</a> <em class="jxr_javadoccomment"> * Delegates to {@link #usage(PrintStream, Help.ColorScheme)} with the {@linkplain Help#defaultColorScheme(CommandLine.Help.Ansi) default color scheme}.</em>
<a class="jxr_linenumber" name="L708" href="#L708">708</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L709" href="#L709">709</a> <em class="jxr_javadoccomment"> * @param ansi whether the usage message should include ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L710" href="#L710">710</a> <em class="jxr_javadoccomment"> * @see #usage(PrintStream, Help.ColorScheme)</em>
<a class="jxr_linenumber" name="L711" href="#L711">711</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L712" href="#L712">712</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> usage(<strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi) {
<a class="jxr_linenumber" name="L713" href="#L713">713</a> usage(out, Help.defaultColorScheme(ansi));
<a class="jxr_linenumber" name="L714" href="#L714">714</a> }
<a class="jxr_linenumber" name="L715" href="#L715">715</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L716" href="#L716">716</a> <em class="jxr_javadoccomment"> * Prints a usage help message for the annotated command class to the specified {@code PrintStream}.</em>
<a class="jxr_linenumber" name="L717" href="#L717">717</a> <em class="jxr_javadoccomment"> * Delegates construction of the usage help message to the {@link Help} inner class and is equivalent to:</em>
<a class="jxr_linenumber" name="L718" href="#L718">718</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L719" href="#L719">719</a> <em class="jxr_javadoccomment"> * Help help = new Help(command).addAllSubcommands(getSubcommands());</em>
<a class="jxr_linenumber" name="L720" href="#L720">720</a> <em class="jxr_javadoccomment"> * StringBuilder sb = new StringBuilder()</em>
<a class="jxr_linenumber" name="L721" href="#L721">721</a> <em class="jxr_javadoccomment"> * .append(help.headerHeading())</em>
<a class="jxr_linenumber" name="L722" href="#L722">722</a> <em class="jxr_javadoccomment"> * .append(help.header())</em>
<a class="jxr_linenumber" name="L723" href="#L723">723</a> <em class="jxr_javadoccomment"> * .append(help.synopsisHeading()) //e.g. Usage:</em>
<a class="jxr_linenumber" name="L724" href="#L724">724</a> <em class="jxr_javadoccomment"> * .append(help.synopsis()) //e.g. &amp;lt;main class&amp;gt; [OPTIONS] &amp;lt;command&amp;gt; [COMMAND-OPTIONS] [ARGUMENTS]</em>
<a class="jxr_linenumber" name="L725" href="#L725">725</a> <em class="jxr_javadoccomment"> * .append(help.descriptionHeading()) //e.g. %nDescription:%n%n</em>
<a class="jxr_linenumber" name="L726" href="#L726">726</a> <em class="jxr_javadoccomment"> * .append(help.description()) //e.g. {"Converts foos to bars.", "Use options to control conversion mode."}</em>
<a class="jxr_linenumber" name="L727" href="#L727">727</a> <em class="jxr_javadoccomment"> * .append(help.parameterListHeading()) //e.g. %nPositional parameters:%n%n</em>
<a class="jxr_linenumber" name="L728" href="#L728">728</a> <em class="jxr_javadoccomment"> * .append(help.parameterList()) //e.g. [FILE...] the files to convert</em>
<a class="jxr_linenumber" name="L729" href="#L729">729</a> <em class="jxr_javadoccomment"> * .append(help.optionListHeading()) //e.g. %nOptions:%n%n</em>
<a class="jxr_linenumber" name="L730" href="#L730">730</a> <em class="jxr_javadoccomment"> * .append(help.optionList()) //e.g. -h, --help displays this help and exits</em>
<a class="jxr_linenumber" name="L731" href="#L731">731</a> <em class="jxr_javadoccomment"> * .append(help.commandListHeading()) //e.g. %nCommands:%n%n</em>
<a class="jxr_linenumber" name="L732" href="#L732">732</a> <em class="jxr_javadoccomment"> * .append(help.commandList()) //e.g. add adds the frup to the frooble</em>
<a class="jxr_linenumber" name="L733" href="#L733">733</a> <em class="jxr_javadoccomment"> * .append(help.footerHeading())</em>
<a class="jxr_linenumber" name="L734" href="#L734">734</a> <em class="jxr_javadoccomment"> * .append(help.footer());</em>
<a class="jxr_linenumber" name="L735" href="#L735">735</a> <em class="jxr_javadoccomment"> * out.print(sb);</em>
<a class="jxr_linenumber" name="L736" href="#L736">736</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L737" href="#L737">737</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Annotate your class with {@link Command} to control many aspects of the usage help message, including</em>
<a class="jxr_linenumber" name="L738" href="#L738">738</a> <em class="jxr_javadoccomment"> * the program name, text of section headings and section contents, and some aspects of the auto-generated sections</em>
<a class="jxr_linenumber" name="L739" href="#L739">739</a> <em class="jxr_javadoccomment"> * of the usage help message.</em>
<a class="jxr_linenumber" name="L740" href="#L740">740</a> <em class="jxr_javadoccomment"> * &lt;p&gt;To customize the auto-generated sections of the usage help message, like how option details are displayed,</em>
<a class="jxr_linenumber" name="L741" href="#L741">741</a> <em class="jxr_javadoccomment"> * instantiate a {@link Help} object and use a {@link Help.TextTable} with more of fewer columns, a custom</em>
<a class="jxr_linenumber" name="L742" href="#L742">742</a> <em class="jxr_javadoccomment"> * {@linkplain Help.Layout layout}, and/or a custom option {@linkplain Help.IOptionRenderer renderer}</em>
<a class="jxr_linenumber" name="L743" href="#L743">743</a> <em class="jxr_javadoccomment"> * for ultimate control over which aspects of an Option or Field are displayed where.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L744" href="#L744">744</a> <em class="jxr_javadoccomment"> * @param out the {@code PrintStream} to print the usage help message to</em>
<a class="jxr_linenumber" name="L745" href="#L745">745</a> <em class="jxr_javadoccomment"> * @param colorScheme the {@code ColorScheme} defining the styles for options, parameters and commands when ANSI is enabled</em>
<a class="jxr_linenumber" name="L746" href="#L746">746</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L747" href="#L747">747</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> usage(<strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.ColorScheme colorScheme) {
<a class="jxr_linenumber" name="L748" href="#L748">748</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a> help = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a>(interpreter.command, colorScheme).addAllSubcommands(getSubcommands());
<a class="jxr_linenumber" name="L749" href="#L749">749</a> <strong class="jxr_keyword">if</strong> (!Help.DEFAULT_SEPARATOR.equals(getSeparator())) {
<a class="jxr_linenumber" name="L750" href="#L750">750</a> help.separator = getSeparator();
<a class="jxr_linenumber" name="L751" href="#L751">751</a> help.parameterLabelRenderer = help.createDefaultParamLabelRenderer(); <em class="jxr_comment">// update for new separator</em>
<a class="jxr_linenumber" name="L752" href="#L752">752</a> }
<a class="jxr_linenumber" name="L753" href="#L753">753</a> <strong class="jxr_keyword">if</strong> (!Help.DEFAULT_COMMAND_NAME.equals(getCommandName())) {
<a class="jxr_linenumber" name="L754" href="#L754">754</a> help.commandName = getCommandName();
<a class="jxr_linenumber" name="L755" href="#L755">755</a> }
<a class="jxr_linenumber" name="L756" href="#L756">756</a> <strong class="jxr_keyword">final</strong> StringBuilder sb = <strong class="jxr_keyword">new</strong> StringBuilder()
<a class="jxr_linenumber" name="L757" href="#L757">757</a> .append(help.headerHeading())
<a class="jxr_linenumber" name="L758" href="#L758">758</a> .append(help.header())
<a class="jxr_linenumber" name="L759" href="#L759">759</a> .append(help.synopsisHeading()) <em class="jxr_comment">//e.g. Usage:</em>
<a class="jxr_linenumber" name="L760" href="#L760">760</a> .append(help.synopsis(help.synopsisHeadingLength())) <em class="jxr_comment">//e.g. &amp;lt;main class&amp;gt; [OPTIONS] &amp;lt;command&amp;gt; [COMMAND-OPTIONS] [ARGUMENTS]</em>
<a class="jxr_linenumber" name="L761" href="#L761">761</a> .append(help.descriptionHeading()) <em class="jxr_comment">//e.g. %nDescription:%n%n</em>
<a class="jxr_linenumber" name="L762" href="#L762">762</a> .append(help.description()) <em class="jxr_comment">//e.g. {"Converts foos to bars.", "Use options to control conversion mode."}</em>
<a class="jxr_linenumber" name="L763" href="#L763">763</a> .append(help.parameterListHeading()) <em class="jxr_comment">//e.g. %nPositional parameters:%n%n</em>
<a class="jxr_linenumber" name="L764" href="#L764">764</a> .append(help.parameterList()) <em class="jxr_comment">//e.g. [FILE...] the files to convert</em>
<a class="jxr_linenumber" name="L765" href="#L765">765</a> .append(help.optionListHeading()) <em class="jxr_comment">//e.g. %nOptions:%n%n</em>
<a class="jxr_linenumber" name="L766" href="#L766">766</a> .append(help.optionList()) <em class="jxr_comment">//e.g. -h, --help displays this help and exits</em>
<a class="jxr_linenumber" name="L767" href="#L767">767</a> .append(help.commandListHeading()) <em class="jxr_comment">//e.g. %nCommands:%n%n</em>
<a class="jxr_linenumber" name="L768" href="#L768">768</a> .append(help.commandList()) <em class="jxr_comment">//e.g. add adds the frup to the frooble</em>
<a class="jxr_linenumber" name="L769" href="#L769">769</a> .append(help.footerHeading())
<a class="jxr_linenumber" name="L770" href="#L770">770</a> .append(help.footer());
<a class="jxr_linenumber" name="L771" href="#L771">771</a> out.print(sb);
<a class="jxr_linenumber" name="L772" href="#L772">772</a> }
<a class="jxr_linenumber" name="L773" href="#L773">773</a>
<a class="jxr_linenumber" name="L774" href="#L774">774</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L775" href="#L775">775</a> <em class="jxr_javadoccomment"> * Delegates to {@link #printVersionHelp(PrintStream, Help.Ansi)} with the {@linkplain Help.Ansi#AUTO platform default}.</em>
<a class="jxr_linenumber" name="L776" href="#L776">776</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L777" href="#L777">777</a> <em class="jxr_javadoccomment"> * @see #printVersionHelp(PrintStream, Help.Ansi)</em>
<a class="jxr_linenumber" name="L778" href="#L778">778</a> <em class="jxr_javadoccomment"> * @since 0.9.8</em>
<a class="jxr_linenumber" name="L779" href="#L779">779</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L780" href="#L780">780</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> printVersionHelp(<strong class="jxr_keyword">final</strong> PrintStream out) { printVersionHelp(out, Help.Ansi.AUTO); }
<a class="jxr_linenumber" name="L781" href="#L781">781</a>
<a class="jxr_linenumber" name="L782" href="#L782">782</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L783" href="#L783">783</a> <em class="jxr_javadoccomment"> * Prints version information from the {@link Command#version()} annotation to the specified {@code PrintStream}.</em>
<a class="jxr_linenumber" name="L784" href="#L784">784</a> <em class="jxr_javadoccomment"> * Each element of the array of version strings is printed on a separate line. Version strings may contain</em>
<a class="jxr_linenumber" name="L785" href="#L785">785</a> <em class="jxr_javadoccomment"> * &lt;a href="<a href="http://picocli.info/" target="alexandria_uri">http://picocli.info/</a>#_usage_help_with_styles_and_colors"&gt;markup for colors and style&lt;/a&gt;.</em>
<a class="jxr_linenumber" name="L786" href="#L786">786</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L787" href="#L787">787</a> <em class="jxr_javadoccomment"> * @param ansi whether the usage message should include ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L788" href="#L788">788</a> <em class="jxr_javadoccomment"> * @see Command#version()</em>
<a class="jxr_linenumber" name="L789" href="#L789">789</a> <em class="jxr_javadoccomment"> * @see Option#versionHelp()</em>
<a class="jxr_linenumber" name="L790" href="#L790">790</a> <em class="jxr_javadoccomment"> * @see #isVersionHelpRequested()</em>
<a class="jxr_linenumber" name="L791" href="#L791">791</a> <em class="jxr_javadoccomment"> * @since 0.9.8</em>
<a class="jxr_linenumber" name="L792" href="#L792">792</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L793" href="#L793">793</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> printVersionHelp(<strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi) {
<a class="jxr_linenumber" name="L794" href="#L794">794</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> String versionInfo : versionLines) {
<a class="jxr_linenumber" name="L795" href="#L795">795</a> out.println(ansi.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(versionInfo));
<a class="jxr_linenumber" name="L796" href="#L796">796</a> }
<a class="jxr_linenumber" name="L797" href="#L797">797</a> }
<a class="jxr_linenumber" name="L798" href="#L798">798</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L799" href="#L799">799</a> <em class="jxr_javadoccomment"> * Prints version information from the {@link Command#version()} annotation to the specified {@code PrintStream}.</em>
<a class="jxr_linenumber" name="L800" href="#L800">800</a> <em class="jxr_javadoccomment"> * Each element of the array of version strings is {@linkplain String#format(String, Object...) formatted} with the</em>
<a class="jxr_linenumber" name="L801" href="#L801">801</a> <em class="jxr_javadoccomment"> * specified parameters, and printed on a separate line. Both version strings and parameters may contain</em>
<a class="jxr_linenumber" name="L802" href="#L802">802</a> <em class="jxr_javadoccomment"> * &lt;a href="<a href="http://picocli.info/" target="alexandria_uri">http://picocli.info/</a>#_usage_help_with_styles_and_colors"&gt;markup for colors and style&lt;/a&gt;.</em>
<a class="jxr_linenumber" name="L803" href="#L803">803</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L804" href="#L804">804</a> <em class="jxr_javadoccomment"> * @param ansi whether the usage message should include ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L805" href="#L805">805</a> <em class="jxr_javadoccomment"> * @param params Arguments referenced by the format specifiers in the version strings</em>
<a class="jxr_linenumber" name="L806" href="#L806">806</a> <em class="jxr_javadoccomment"> * @see Command#version()</em>
<a class="jxr_linenumber" name="L807" href="#L807">807</a> <em class="jxr_javadoccomment"> * @see Option#versionHelp()</em>
<a class="jxr_linenumber" name="L808" href="#L808">808</a> <em class="jxr_javadoccomment"> * @see #isVersionHelpRequested()</em>
<a class="jxr_linenumber" name="L809" href="#L809">809</a> <em class="jxr_javadoccomment"> * @since 1.0.0</em>
<a class="jxr_linenumber" name="L810" href="#L810">810</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L811" href="#L811">811</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> printVersionHelp(<strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi, <strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L812" href="#L812">812</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> String versionInfo : versionLines) {
<a class="jxr_linenumber" name="L813" href="#L813">813</a> out.println(ansi.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(String.format(versionInfo, params)));
<a class="jxr_linenumber" name="L814" href="#L814">814</a> }
<a class="jxr_linenumber" name="L815" href="#L815">815</a> }
<a class="jxr_linenumber" name="L816" href="#L816">816</a>
<a class="jxr_linenumber" name="L817" href="#L817">817</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L818" href="#L818">818</a> <em class="jxr_javadoccomment"> * Delegates to {@link #call(Callable, PrintStream, Help.Ansi, String...)} with {@link Help.Ansi#AUTO}.</em>
<a class="jxr_linenumber" name="L819" href="#L819">819</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L820" href="#L820">820</a> <em class="jxr_javadoccomment"> * From picocli v2.0, this method prints usage help or version help if {@linkplain #printHelpIfRequested(List, PrintStream, Help.Ansi) requested},</em>
<a class="jxr_linenumber" name="L821" href="#L821">821</a> <em class="jxr_javadoccomment"> * and any exceptions thrown by the {@code Callable} are caught and rethrown wrapped in an {@code ExecutionException}.</em>
<a class="jxr_linenumber" name="L822" href="#L822">822</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L823" href="#L823">823</a> <em class="jxr_javadoccomment"> * @param callable the command to call when {@linkplain #parse(String...) parsing} succeeds.</em>
<a class="jxr_linenumber" name="L824" href="#L824">824</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L825" href="#L825">825</a> <em class="jxr_javadoccomment"> * @param args the command line arguments to parse</em>
<a class="jxr_linenumber" name="L826" href="#L826">826</a> <em class="jxr_javadoccomment"> * @param &lt;C&gt; the annotated object must implement Callable</em>
<a class="jxr_linenumber" name="L827" href="#L827">827</a> <em class="jxr_javadoccomment"> * @param &lt;T&gt; the return type of the most specific command (must implement {@code Callable})</em>
<a class="jxr_linenumber" name="L828" href="#L828">828</a> <em class="jxr_javadoccomment"> * @see #call(Callable, PrintStream, Help.Ansi, String...)</em>
<a class="jxr_linenumber" name="L829" href="#L829">829</a> <em class="jxr_javadoccomment"> * @throws InitializationException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L830" href="#L830">830</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if the Callable throws an exception</em>
<a class="jxr_linenumber" name="L831" href="#L831">831</a> <em class="jxr_javadoccomment"> * @return {@code null} if an error occurred while parsing the command line options, otherwise returns the result of calling the Callable</em>
<a class="jxr_linenumber" name="L832" href="#L832">832</a> <em class="jxr_javadoccomment"> * @see #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...)</em>
<a class="jxr_linenumber" name="L833" href="#L833">833</a> <em class="jxr_javadoccomment"> * @see RunFirst</em>
<a class="jxr_linenumber" name="L834" href="#L834">834</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L835" href="#L835">835</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> &lt;C <strong class="jxr_keyword">extends</strong> Callable&lt;T&gt;, T&gt; T call(<strong class="jxr_keyword">final</strong> C callable, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L836" href="#L836">836</a> <strong class="jxr_keyword">return</strong> call(callable, out, Help.Ansi.AUTO, args);
<a class="jxr_linenumber" name="L837" href="#L837">837</a> }
<a class="jxr_linenumber" name="L838" href="#L838">838</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L839" href="#L839">839</a> <em class="jxr_javadoccomment"> * Convenience method to allow command line application authors to avoid some boilerplate code in their application.</em>
<a class="jxr_linenumber" name="L840" href="#L840">840</a> <em class="jxr_javadoccomment"> * The annotated object needs to implement {@link Callable}. Calling this method is equivalent to:</em>
<a class="jxr_linenumber" name="L841" href="#L841">841</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L842" href="#L842">842</a> <em class="jxr_javadoccomment"> * CommandLine cmd = new CommandLine(callable);</em>
<a class="jxr_linenumber" name="L843" href="#L843">843</a> <em class="jxr_javadoccomment"> * List&amp;lt;CommandLine&amp;gt; parsedCommands;</em>
<a class="jxr_linenumber" name="L844" href="#L844">844</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L845" href="#L845">845</a> <em class="jxr_javadoccomment"> * parsedCommands = cmd.parse(args);</em>
<a class="jxr_linenumber" name="L846" href="#L846">846</a> <em class="jxr_javadoccomment"> * } catch (ParameterException ex) {</em>
<a class="jxr_linenumber" name="L847" href="#L847">847</a> <em class="jxr_javadoccomment"> * out.println(ex.getMessage());</em>
<a class="jxr_linenumber" name="L848" href="#L848">848</a> <em class="jxr_javadoccomment"> * cmd.usage(out, ansi);</em>
<a class="jxr_linenumber" name="L849" href="#L849">849</a> <em class="jxr_javadoccomment"> * return null;</em>
<a class="jxr_linenumber" name="L850" href="#L850">850</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L851" href="#L851">851</a> <em class="jxr_javadoccomment"> * if (CommandLine.printHelpIfRequested(parsedCommands, out, ansi)) {</em>
<a class="jxr_linenumber" name="L852" href="#L852">852</a> <em class="jxr_javadoccomment"> * return null;</em>
<a class="jxr_linenumber" name="L853" href="#L853">853</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L854" href="#L854">854</a> <em class="jxr_javadoccomment"> * CommandLine last = parsedCommands.get(parsedCommands.size() - 1);</em>
<a class="jxr_linenumber" name="L855" href="#L855">855</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L856" href="#L856">856</a> <em class="jxr_javadoccomment"> * Callable&amp;lt;Object&amp;gt; subcommand = last.getCommand();</em>
<a class="jxr_linenumber" name="L857" href="#L857">857</a> <em class="jxr_javadoccomment"> * return subcommand.call();</em>
<a class="jxr_linenumber" name="L858" href="#L858">858</a> <em class="jxr_javadoccomment"> * } catch (Exception ex) {</em>
<a class="jxr_linenumber" name="L859" href="#L859">859</a> <em class="jxr_javadoccomment"> * throw new ExecutionException(last, "Error calling " + last.getCommand(), ex);</em>
<a class="jxr_linenumber" name="L860" href="#L860">860</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L861" href="#L861">861</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L862" href="#L862">862</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L863" href="#L863">863</a> <em class="jxr_javadoccomment"> * If the specified Callable command has subcommands, the {@linkplain RunLast last} subcommand specified on the</em>
<a class="jxr_linenumber" name="L864" href="#L864">864</a> <em class="jxr_javadoccomment"> * command line is executed.</em>
<a class="jxr_linenumber" name="L865" href="#L865">865</a> <em class="jxr_javadoccomment"> * Commands with subcommands may be interested in calling the {@link #parseWithHandler(IParseResultHandler, PrintStream, String...) parseWithHandler}</em>
<a class="jxr_linenumber" name="L866" href="#L866">866</a> <em class="jxr_javadoccomment"> * method with a {@link RunAll} handler or a custom handler.</em>
<a class="jxr_linenumber" name="L867" href="#L867">867</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L868" href="#L868">868</a> <em class="jxr_javadoccomment"> * From picocli v2.0, this method prints usage help or version help if {@linkplain #printHelpIfRequested(List, PrintStream, Help.Ansi) requested},</em>
<a class="jxr_linenumber" name="L869" href="#L869">869</a> <em class="jxr_javadoccomment"> * and any exceptions thrown by the {@code Callable} are caught and rethrown wrapped in an {@code ExecutionException}.</em>
<a class="jxr_linenumber" name="L870" href="#L870">870</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L871" href="#L871">871</a> <em class="jxr_javadoccomment"> * @param callable the command to call when {@linkplain #parse(String...) parsing} succeeds.</em>
<a class="jxr_linenumber" name="L872" href="#L872">872</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L873" href="#L873">873</a> <em class="jxr_javadoccomment"> * @param ansi whether the usage message should include ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L874" href="#L874">874</a> <em class="jxr_javadoccomment"> * @param args the command line arguments to parse</em>
<a class="jxr_linenumber" name="L875" href="#L875">875</a> <em class="jxr_javadoccomment"> * @param &lt;C&gt; the annotated object must implement Callable</em>
<a class="jxr_linenumber" name="L876" href="#L876">876</a> <em class="jxr_javadoccomment"> * @param &lt;T&gt; the return type of the specified {@code Callable}</em>
<a class="jxr_linenumber" name="L877" href="#L877">877</a> <em class="jxr_javadoccomment"> * @throws InitializationException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L878" href="#L878">878</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if the Callable throws an exception</em>
<a class="jxr_linenumber" name="L879" href="#L879">879</a> <em class="jxr_javadoccomment"> * @return {@code null} if an error occurred while parsing the command line options, or if help was requested and printed. Otherwise returns the result of calling the Callable</em>
<a class="jxr_linenumber" name="L880" href="#L880">880</a> <em class="jxr_javadoccomment"> * @see #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...)</em>
<a class="jxr_linenumber" name="L881" href="#L881">881</a> <em class="jxr_javadoccomment"> * @see RunLast</em>
<a class="jxr_linenumber" name="L882" href="#L882">882</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L883" href="#L883">883</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> &lt;C <strong class="jxr_keyword">extends</strong> Callable&lt;T&gt;, T&gt; T call(<strong class="jxr_keyword">final</strong> C callable, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi, <strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L884" href="#L884">884</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> cmd = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a>(callable); <em class="jxr_comment">// validate command outside of try-catch</em>
<a class="jxr_linenumber" name="L885" href="#L885">885</a> <strong class="jxr_keyword">final</strong> List&lt;Object&gt; results = cmd.parseWithHandlers(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">RunLast</a>(), out, ansi, <strong class="jxr_keyword">new</strong> DefaultExceptionHandler(), args);
<a class="jxr_linenumber" name="L886" href="#L886">886</a> <strong class="jxr_keyword">return</strong> results == <strong class="jxr_keyword">null</strong> || results.isEmpty() ? <strong class="jxr_keyword">null</strong> : (T) results.get(0);
<a class="jxr_linenumber" name="L887" href="#L887">887</a> }
<a class="jxr_linenumber" name="L888" href="#L888">888</a>
<a class="jxr_linenumber" name="L889" href="#L889">889</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L890" href="#L890">890</a> <em class="jxr_javadoccomment"> * Delegates to {@link #run(Runnable, PrintStream, Help.Ansi, String...)} with {@link Help.Ansi#AUTO}.</em>
<a class="jxr_linenumber" name="L891" href="#L891">891</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L892" href="#L892">892</a> <em class="jxr_javadoccomment"> * From picocli v2.0, this method prints usage help or version help if {@linkplain #printHelpIfRequested(List, PrintStream, Help.Ansi) requested},</em>
<a class="jxr_linenumber" name="L893" href="#L893">893</a> <em class="jxr_javadoccomment"> * and any exceptions thrown by the {@code Runnable} are caught and rethrown wrapped in an {@code ExecutionException}.</em>
<a class="jxr_linenumber" name="L894" href="#L894">894</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L895" href="#L895">895</a> <em class="jxr_javadoccomment"> * @param runnable the command to run when {@linkplain #parse(String...) parsing} succeeds.</em>
<a class="jxr_linenumber" name="L896" href="#L896">896</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L897" href="#L897">897</a> <em class="jxr_javadoccomment"> * @param args the command line arguments to parse</em>
<a class="jxr_linenumber" name="L898" href="#L898">898</a> <em class="jxr_javadoccomment"> * @param &lt;R&gt; the annotated object must implement Runnable</em>
<a class="jxr_linenumber" name="L899" href="#L899">899</a> <em class="jxr_javadoccomment"> * @see #run(Runnable, PrintStream, Help.Ansi, String...)</em>
<a class="jxr_linenumber" name="L900" href="#L900">900</a> <em class="jxr_javadoccomment"> * @throws InitializationException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L901" href="#L901">901</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if the Runnable throws an exception</em>
<a class="jxr_linenumber" name="L902" href="#L902">902</a> <em class="jxr_javadoccomment"> * @see #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...)</em>
<a class="jxr_linenumber" name="L903" href="#L903">903</a> <em class="jxr_javadoccomment"> * @see RunFirst</em>
<a class="jxr_linenumber" name="L904" href="#L904">904</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L905" href="#L905">905</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> &lt;R <strong class="jxr_keyword">extends</strong> Runnable&gt; <strong class="jxr_keyword">void</strong> run(<strong class="jxr_keyword">final</strong> R runnable, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L906" href="#L906">906</a> run(runnable, out, Help.Ansi.AUTO, args);
<a class="jxr_linenumber" name="L907" href="#L907">907</a> }
<a class="jxr_linenumber" name="L908" href="#L908">908</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L909" href="#L909">909</a> <em class="jxr_javadoccomment"> * Convenience method to allow command line application authors to avoid some boilerplate code in their application.</em>
<a class="jxr_linenumber" name="L910" href="#L910">910</a> <em class="jxr_javadoccomment"> * The annotated object needs to implement {@link Runnable}. Calling this method is equivalent to:</em>
<a class="jxr_linenumber" name="L911" href="#L911">911</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L912" href="#L912">912</a> <em class="jxr_javadoccomment"> * CommandLine cmd = new CommandLine(runnable);</em>
<a class="jxr_linenumber" name="L913" href="#L913">913</a> <em class="jxr_javadoccomment"> * List&amp;lt;CommandLine&amp;gt; parsedCommands;</em>
<a class="jxr_linenumber" name="L914" href="#L914">914</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L915" href="#L915">915</a> <em class="jxr_javadoccomment"> * parsedCommands = cmd.parse(args);</em>
<a class="jxr_linenumber" name="L916" href="#L916">916</a> <em class="jxr_javadoccomment"> * } catch (ParameterException ex) {</em>
<a class="jxr_linenumber" name="L917" href="#L917">917</a> <em class="jxr_javadoccomment"> * out.println(ex.getMessage());</em>
<a class="jxr_linenumber" name="L918" href="#L918">918</a> <em class="jxr_javadoccomment"> * cmd.usage(out, ansi);</em>
<a class="jxr_linenumber" name="L919" href="#L919">919</a> <em class="jxr_javadoccomment"> * return null;</em>
<a class="jxr_linenumber" name="L920" href="#L920">920</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L921" href="#L921">921</a> <em class="jxr_javadoccomment"> * if (CommandLine.printHelpIfRequested(parsedCommands, out, ansi)) {</em>
<a class="jxr_linenumber" name="L922" href="#L922">922</a> <em class="jxr_javadoccomment"> * return null;</em>
<a class="jxr_linenumber" name="L923" href="#L923">923</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L924" href="#L924">924</a> <em class="jxr_javadoccomment"> * CommandLine last = parsedCommands.get(parsedCommands.size() - 1);</em>
<a class="jxr_linenumber" name="L925" href="#L925">925</a> <em class="jxr_javadoccomment"> * try {</em>
<a class="jxr_linenumber" name="L926" href="#L926">926</a> <em class="jxr_javadoccomment"> * Runnable subcommand = last.getCommand();</em>
<a class="jxr_linenumber" name="L927" href="#L927">927</a> <em class="jxr_javadoccomment"> * subcommand.run();</em>
<a class="jxr_linenumber" name="L928" href="#L928">928</a> <em class="jxr_javadoccomment"> * } catch (Exception ex) {</em>
<a class="jxr_linenumber" name="L929" href="#L929">929</a> <em class="jxr_javadoccomment"> * throw new ExecutionException(last, "Error running " + last.getCommand(), ex);</em>
<a class="jxr_linenumber" name="L930" href="#L930">930</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L931" href="#L931">931</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L932" href="#L932">932</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L933" href="#L933">933</a> <em class="jxr_javadoccomment"> * If the specified Runnable command has subcommands, the {@linkplain RunLast last} subcommand specified on the</em>
<a class="jxr_linenumber" name="L934" href="#L934">934</a> <em class="jxr_javadoccomment"> * command line is executed.</em>
<a class="jxr_linenumber" name="L935" href="#L935">935</a> <em class="jxr_javadoccomment"> * Commands with subcommands may be interested in calling the {@link #parseWithHandler(IParseResultHandler, PrintStream, String...) parseWithHandler}</em>
<a class="jxr_linenumber" name="L936" href="#L936">936</a> <em class="jxr_javadoccomment"> * method with a {@link RunAll} handler or a custom handler.</em>
<a class="jxr_linenumber" name="L937" href="#L937">937</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L938" href="#L938">938</a> <em class="jxr_javadoccomment"> * From picocli v2.0, this method prints usage help or version help if {@linkplain #printHelpIfRequested(List, PrintStream, Help.Ansi) requested},</em>
<a class="jxr_linenumber" name="L939" href="#L939">939</a> <em class="jxr_javadoccomment"> * and any exceptions thrown by the {@code Runnable} are caught and rethrown wrapped in an {@code ExecutionException}.</em>
<a class="jxr_linenumber" name="L940" href="#L940">940</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L941" href="#L941">941</a> <em class="jxr_javadoccomment"> * @param runnable the command to run when {@linkplain #parse(String...) parsing} succeeds.</em>
<a class="jxr_linenumber" name="L942" href="#L942">942</a> <em class="jxr_javadoccomment"> * @param out the printStream to print to</em>
<a class="jxr_linenumber" name="L943" href="#L943">943</a> <em class="jxr_javadoccomment"> * @param ansi whether the usage message should include ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L944" href="#L944">944</a> <em class="jxr_javadoccomment"> * @param args the command line arguments to parse</em>
<a class="jxr_linenumber" name="L945" href="#L945">945</a> <em class="jxr_javadoccomment"> * @param &lt;R&gt; the annotated object must implement Runnable</em>
<a class="jxr_linenumber" name="L946" href="#L946">946</a> <em class="jxr_javadoccomment"> * @throws InitializationException if the specified command object does not have a {@link Command}, {@link Option} or {@link Parameters} annotation</em>
<a class="jxr_linenumber" name="L947" href="#L947">947</a> <em class="jxr_javadoccomment"> * @throws ExecutionException if the Runnable throws an exception</em>
<a class="jxr_linenumber" name="L948" href="#L948">948</a> <em class="jxr_javadoccomment"> * @see #parseWithHandlers(IParseResultHandler, PrintStream, Help.Ansi, IExceptionHandler, String...)</em>
<a class="jxr_linenumber" name="L949" href="#L949">949</a> <em class="jxr_javadoccomment"> * @see RunLast</em>
<a class="jxr_linenumber" name="L950" href="#L950">950</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L951" href="#L951">951</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> &lt;R <strong class="jxr_keyword">extends</strong> Runnable&gt; <strong class="jxr_keyword">void</strong> run(<strong class="jxr_keyword">final</strong> R runnable, <strong class="jxr_keyword">final</strong> PrintStream out, <strong class="jxr_keyword">final</strong> Help.Ansi ansi, <strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L952" href="#L952">952</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> cmd = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a>(runnable); <em class="jxr_comment">// validate command outside of try-catch</em>
<a class="jxr_linenumber" name="L953" href="#L953">953</a> cmd.parseWithHandlers(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">RunLast</a>(), out, ansi, <strong class="jxr_keyword">new</strong> DefaultExceptionHandler(), args);
<a class="jxr_linenumber" name="L954" href="#L954">954</a> }
<a class="jxr_linenumber" name="L955" href="#L955">955</a>
<a class="jxr_linenumber" name="L956" href="#L956">956</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L957" href="#L957">957</a> <em class="jxr_javadoccomment"> * Registers the specified type converter for the specified class. When initializing fields annotated with</em>
<a class="jxr_linenumber" name="L958" href="#L958">958</a> <em class="jxr_javadoccomment"> * {@link Option}, the field's type is used as a lookup key to find the associated type converter, and this</em>
<a class="jxr_linenumber" name="L959" href="#L959">959</a> <em class="jxr_javadoccomment"> * type converter converts the original command line argument string value to the correct type.</em>
<a class="jxr_linenumber" name="L960" href="#L960">960</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L961" href="#L961">961</a> <em class="jxr_javadoccomment"> * Java 8 lambdas make it easy to register custom type converters:</em>
<a class="jxr_linenumber" name="L962" href="#L962">962</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L963" href="#L963">963</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L964" href="#L964">964</a> <em class="jxr_javadoccomment"> * commandLine.registerConverter(java.nio.file.Path.class, s -&amp;gt; java.nio.file.Paths.get(s));</em>
<a class="jxr_linenumber" name="L965" href="#L965">965</a> <em class="jxr_javadoccomment"> * commandLine.registerConverter(java.time.Duration.class, s -&amp;gt; java.time.Duration.parse(s));&lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L966" href="#L966">966</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L967" href="#L967">967</a> <em class="jxr_javadoccomment"> * Built-in type converters are pre-registered for the following java 1.5 types:</em>
<a class="jxr_linenumber" name="L968" href="#L968">968</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L969" href="#L969">969</a> <em class="jxr_javadoccomment"> * &lt;ul&gt;</em>
<a class="jxr_linenumber" name="L970" href="#L970">970</a> <em class="jxr_javadoccomment"> * &lt;li&gt;all primitive types&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L971" href="#L971">971</a> <em class="jxr_javadoccomment"> * &lt;li&gt;all primitive wrapper types: Boolean, Byte, Character, Double, Float, Integer, Long, Short&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L972" href="#L972">972</a> <em class="jxr_javadoccomment"> * &lt;li&gt;any enum&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L973" href="#L973">973</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.io.File&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L974" href="#L974">974</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.math.BigDecimal&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L975" href="#L975">975</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.math.BigInteger&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L976" href="#L976">976</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.net.InetAddress&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L977" href="#L977">977</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.net.URI&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L978" href="#L978">978</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.net.URL&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L979" href="#L979">979</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.nio.charset.Charset&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L980" href="#L980">980</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.sql.Time&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L981" href="#L981">981</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.util.Date&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L982" href="#L982">982</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.util.UUID&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L983" href="#L983">983</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.util.regex.Pattern&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L984" href="#L984">984</a> <em class="jxr_javadoccomment"> * &lt;li&gt;StringBuilder&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L985" href="#L985">985</a> <em class="jxr_javadoccomment"> * &lt;li&gt;CharSequence&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L986" href="#L986">986</a> <em class="jxr_javadoccomment"> * &lt;li&gt;String&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L987" href="#L987">987</a> <em class="jxr_javadoccomment"> * &lt;/ul&gt;</em>
<a class="jxr_linenumber" name="L988" href="#L988">988</a> <em class="jxr_javadoccomment"> * &lt;p&gt;The specified converter will be registered with this {@code CommandLine} and the full hierarchy of its</em>
<a class="jxr_linenumber" name="L989" href="#L989">989</a> <em class="jxr_javadoccomment"> * subcommands and nested sub-subcommands &lt;em&gt;at the moment the converter is registered&lt;/em&gt;. Subcommands added</em>
<a class="jxr_linenumber" name="L990" href="#L990">990</a> <em class="jxr_javadoccomment"> * later will not have this converter added automatically. To ensure a custom type converter is available to all</em>
<a class="jxr_linenumber" name="L991" href="#L991">991</a> <em class="jxr_javadoccomment"> * subcommands, register the type converter last, after adding subcommands.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L992" href="#L992">992</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L993" href="#L993">993</a> <em class="jxr_javadoccomment"> * @param cls the target class to convert parameter string values to</em>
<a class="jxr_linenumber" name="L994" href="#L994">994</a> <em class="jxr_javadoccomment"> * @param converter the class capable of converting string values to the specified target type</em>
<a class="jxr_linenumber" name="L995" href="#L995">995</a> <em class="jxr_javadoccomment"> * @param &lt;K&gt; the target type</em>
<a class="jxr_linenumber" name="L996" href="#L996">996</a> <em class="jxr_javadoccomment"> * @return this CommandLine object, to allow method chaining</em>
<a class="jxr_linenumber" name="L997" href="#L997">997</a> <em class="jxr_javadoccomment"> * @see #addSubcommand(String, Object)</em>
<a class="jxr_linenumber" name="L998" href="#L998">998</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L999" href="#L999">999</a> <strong class="jxr_keyword">public</strong> &lt;K&gt; <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> registerConverter(<strong class="jxr_keyword">final</strong> Class&lt;K&gt; cls, <strong class="jxr_keyword">final</strong> ITypeConverter&lt;K&gt; converter) {
<a class="jxr_linenumber" name="L1000" href="#L1000">1000</a> interpreter.converterRegistry.put(Assert.notNull(cls, <span class="jxr_string">"class"</span>), Assert.notNull(converter, <span class="jxr_string">"converter"</span>));
<a class="jxr_linenumber" name="L1001" href="#L1001">1001</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> CommandLine command : interpreter.commands.values()) {
<a class="jxr_linenumber" name="L1002" href="#L1002">1002</a> command.registerConverter(cls, converter);
<a class="jxr_linenumber" name="L1003" href="#L1003">1003</a> }
<a class="jxr_linenumber" name="L1004" href="#L1004">1004</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L1005" href="#L1005">1005</a> }
<a class="jxr_linenumber" name="L1006" href="#L1006">1006</a>
<a class="jxr_linenumber" name="L1007" href="#L1007">1007</a> <em class="jxr_javadoccomment">/** Returns the String that separates option names from option values when parsing command line options. {@value Help#DEFAULT_SEPARATOR} by default.</em>
<a class="jxr_linenumber" name="L1008" href="#L1008">1008</a> <em class="jxr_javadoccomment"> * @return the String the parser uses to separate option names from option values */</em>
<a class="jxr_linenumber" name="L1009" href="#L1009">1009</a> <strong class="jxr_keyword">public</strong> String getSeparator() {
<a class="jxr_linenumber" name="L1010" href="#L1010">1010</a> <strong class="jxr_keyword">return</strong> interpreter.separator;
<a class="jxr_linenumber" name="L1011" href="#L1011">1011</a> }
<a class="jxr_linenumber" name="L1012" href="#L1012">1012</a>
<a class="jxr_linenumber" name="L1013" href="#L1013">1013</a> <em class="jxr_javadoccomment">/** Sets the String the parser uses to separate option names from option values to the specified value.</em>
<a class="jxr_linenumber" name="L1014" href="#L1014">1014</a> <em class="jxr_javadoccomment"> * The separator may also be set declaratively with the {@link CommandLine.Command#separator()} annotation attribute.</em>
<a class="jxr_linenumber" name="L1015" href="#L1015">1015</a> <em class="jxr_javadoccomment"> * @param separator the String that separates option names from option values</em>
<a class="jxr_linenumber" name="L1016" href="#L1016">1016</a> <em class="jxr_javadoccomment"> * @return this {@code CommandLine} object, to allow method chaining */</em>
<a class="jxr_linenumber" name="L1017" href="#L1017">1017</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> setSeparator(<strong class="jxr_keyword">final</strong> String separator) {
<a class="jxr_linenumber" name="L1018" href="#L1018">1018</a> interpreter.separator = Assert.notNull(separator, <span class="jxr_string">"separator"</span>);
<a class="jxr_linenumber" name="L1019" href="#L1019">1019</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L1020" href="#L1020">1020</a> }
<a class="jxr_linenumber" name="L1021" href="#L1021">1021</a>
<a class="jxr_linenumber" name="L1022" href="#L1022">1022</a> <em class="jxr_javadoccomment">/** Returns the command name (also called program name) displayed in the usage help synopsis. {@value Help#DEFAULT_COMMAND_NAME} by default.</em>
<a class="jxr_linenumber" name="L1023" href="#L1023">1023</a> <em class="jxr_javadoccomment"> * @return the command name (also called program name) displayed in the usage */</em>
<a class="jxr_linenumber" name="L1024" href="#L1024">1024</a> <strong class="jxr_keyword">public</strong> String getCommandName() {
<a class="jxr_linenumber" name="L1025" href="#L1025">1025</a> <strong class="jxr_keyword">return</strong> commandName;
<a class="jxr_linenumber" name="L1026" href="#L1026">1026</a> }
<a class="jxr_linenumber" name="L1027" href="#L1027">1027</a>
<a class="jxr_linenumber" name="L1028" href="#L1028">1028</a> <em class="jxr_javadoccomment">/** Sets the command name (also called program name) displayed in the usage help synopsis to the specified value.</em>
<a class="jxr_linenumber" name="L1029" href="#L1029">1029</a> <em class="jxr_javadoccomment"> * Note that this method only modifies the usage help message, it does not impact parsing behaviour.</em>
<a class="jxr_linenumber" name="L1030" href="#L1030">1030</a> <em class="jxr_javadoccomment"> * The command name may also be set declaratively with the {@link CommandLine.Command#name()} annotation attribute.</em>
<a class="jxr_linenumber" name="L1031" href="#L1031">1031</a> <em class="jxr_javadoccomment"> * @param commandName command name (also called program name) displayed in the usage help synopsis</em>
<a class="jxr_linenumber" name="L1032" href="#L1032">1032</a> <em class="jxr_javadoccomment"> * @return this {@code CommandLine} object, to allow method chaining */</em>
<a class="jxr_linenumber" name="L1033" href="#L1033">1033</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> setCommandName(<strong class="jxr_keyword">final</strong> String commandName) {
<a class="jxr_linenumber" name="L1034" href="#L1034">1034</a> <strong class="jxr_keyword">this</strong>.commandName = Assert.notNull(commandName, <span class="jxr_string">"commandName"</span>);
<a class="jxr_linenumber" name="L1035" href="#L1035">1035</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L1036" href="#L1036">1036</a> }
<a class="jxr_linenumber" name="L1037" href="#L1037">1037</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> empty(<strong class="jxr_keyword">final</strong> String str) { <strong class="jxr_keyword">return</strong> str == <strong class="jxr_keyword">null</strong> || str.trim().length() == 0; }
<a class="jxr_linenumber" name="L1038" href="#L1038">1038</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> empty(<strong class="jxr_keyword">final</strong> Object[] array) { <strong class="jxr_keyword">return</strong> array == <strong class="jxr_keyword">null</strong> || array.length == 0; }
<a class="jxr_linenumber" name="L1039" href="#L1039">1039</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> empty(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> txt) { <strong class="jxr_keyword">return</strong> txt == <strong class="jxr_keyword">null</strong> || txt.plain.toString().trim().length() == 0; }
<a class="jxr_linenumber" name="L1040" href="#L1040">1040</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String str(<strong class="jxr_keyword">final</strong> String[] arr, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> i) { <strong class="jxr_keyword">return</strong> (arr == <strong class="jxr_keyword">null</strong> || arr.length == 0) ? <span class="jxr_string">""</span> : arr[i]; }
<a class="jxr_linenumber" name="L1041" href="#L1041">1041</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> isBoolean(<strong class="jxr_keyword">final</strong> Class&lt;?&gt; type) { <strong class="jxr_keyword">return</strong> type == Boolean.<strong class="jxr_keyword">class</strong> || type == Boolean.TYPE; }
<a class="jxr_linenumber" name="L1042" href="#L1042">1042</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> toCommandLine(<strong class="jxr_keyword">final</strong> Object obj) { <strong class="jxr_keyword">return</strong> obj instanceof CommandLine ? (CommandLine) obj : <strong class="jxr_keyword">new</strong> CommandLine(obj);}
<a class="jxr_linenumber" name="L1043" href="#L1043">1043</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> isMultiValue(<strong class="jxr_keyword">final</strong> Field field) { <strong class="jxr_keyword">return</strong> isMultiValue(field.getType()); }
<a class="jxr_linenumber" name="L1044" href="#L1044">1044</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> isMultiValue(<strong class="jxr_keyword">final</strong> Class&lt;?&gt; cls) { <strong class="jxr_keyword">return</strong> cls.isArray() || Collection.<strong class="jxr_keyword">class</strong>.isAssignableFrom(cls) || Map.<strong class="jxr_keyword">class</strong>.isAssignableFrom(cls); }
<a class="jxr_linenumber" name="L1045" href="#L1045">1045</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> Class&lt;?&gt;[] getTypeAttribute(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L1046" href="#L1046">1046</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt;[] explicit = field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>) ? field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).type() : field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).type();
<a class="jxr_linenumber" name="L1047" href="#L1047">1047</a> <strong class="jxr_keyword">if</strong> (explicit.length &gt; 0) { <strong class="jxr_keyword">return</strong> explicit; }
<a class="jxr_linenumber" name="L1048" href="#L1048">1048</a> <strong class="jxr_keyword">if</strong> (field.getType().isArray()) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Class&lt;?&gt;[] { field.getType().getComponentType() }; }
<a class="jxr_linenumber" name="L1049" href="#L1049">1049</a> <strong class="jxr_keyword">if</strong> (isMultiValue(field)) {
<a class="jxr_linenumber" name="L1050" href="#L1050">1050</a> <strong class="jxr_keyword">final</strong> Type type = field.getGenericType(); <em class="jxr_comment">// e.g. Map&lt;Long, ? extends Number&gt;</em>
<a class="jxr_linenumber" name="L1051" href="#L1051">1051</a> <strong class="jxr_keyword">if</strong> (type instanceof ParameterizedType) {
<a class="jxr_linenumber" name="L1052" href="#L1052">1052</a> <strong class="jxr_keyword">final</strong> ParameterizedType parameterizedType = (ParameterizedType) type;
<a class="jxr_linenumber" name="L1053" href="#L1053">1053</a> <strong class="jxr_keyword">final</strong> Type[] paramTypes = parameterizedType.getActualTypeArguments(); <em class="jxr_comment">// e.g. ? extends Number</em>
<a class="jxr_linenumber" name="L1054" href="#L1054">1054</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt;[] result = <strong class="jxr_keyword">new</strong> Class&lt;?&gt;[paramTypes.length];
<a class="jxr_linenumber" name="L1055" href="#L1055">1055</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; paramTypes.length; i++) {
<a class="jxr_linenumber" name="L1056" href="#L1056">1056</a> <strong class="jxr_keyword">if</strong> (paramTypes[i] instanceof Class) { result[i] = (Class&lt;?&gt;) paramTypes[i]; <strong class="jxr_keyword">continue</strong>; } <em class="jxr_comment">// e.g. Long</em>
<a class="jxr_linenumber" name="L1057" href="#L1057">1057</a> <strong class="jxr_keyword">if</strong> (paramTypes[i] instanceof WildcardType) { <em class="jxr_comment">// e.g. ? extends Number</em>
<a class="jxr_linenumber" name="L1058" href="#L1058">1058</a> <strong class="jxr_keyword">final</strong> WildcardType wildcardType = (WildcardType) paramTypes[i];
<a class="jxr_linenumber" name="L1059" href="#L1059">1059</a> <strong class="jxr_keyword">final</strong> Type[] lower = wildcardType.getLowerBounds(); <em class="jxr_comment">// e.g. []</em>
<a class="jxr_linenumber" name="L1060" href="#L1060">1060</a> <strong class="jxr_keyword">if</strong> (lower.length &gt; 0 &amp;&amp; lower[0] instanceof Class) { result[i] = (Class&lt;?&gt;) lower[0]; <strong class="jxr_keyword">continue</strong>; }
<a class="jxr_linenumber" name="L1061" href="#L1061">1061</a> <strong class="jxr_keyword">final</strong> Type[] upper = wildcardType.getUpperBounds(); <em class="jxr_comment">// e.g. Number</em>
<a class="jxr_linenumber" name="L1062" href="#L1062">1062</a> <strong class="jxr_keyword">if</strong> (upper.length &gt; 0 &amp;&amp; upper[0] instanceof Class) { result[i] = (Class&lt;?&gt;) upper[0]; <strong class="jxr_keyword">continue</strong>; }
<a class="jxr_linenumber" name="L1063" href="#L1063">1063</a> }
<a class="jxr_linenumber" name="L1064" href="#L1064">1064</a> Arrays.fill(result, String.<strong class="jxr_keyword">class</strong>); <strong class="jxr_keyword">return</strong> result; <em class="jxr_comment">// too convoluted generic type, giving up</em>
<a class="jxr_linenumber" name="L1065" href="#L1065">1065</a> }
<a class="jxr_linenumber" name="L1066" href="#L1066">1066</a> <strong class="jxr_keyword">return</strong> result; <em class="jxr_comment">// we inferred all types from ParameterizedType</em>
<a class="jxr_linenumber" name="L1067" href="#L1067">1067</a> }
<a class="jxr_linenumber" name="L1068" href="#L1068">1068</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Class&lt;?&gt;[] {String.<strong class="jxr_keyword">class</strong>, String.<strong class="jxr_keyword">class</strong>}; <em class="jxr_comment">// field is multi-value but not ParameterizedType</em>
<a class="jxr_linenumber" name="L1069" href="#L1069">1069</a> }
<a class="jxr_linenumber" name="L1070" href="#L1070">1070</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Class&lt;?&gt;[] {field.getType()}; <em class="jxr_comment">// not a multi-value field</em>
<a class="jxr_linenumber" name="L1071" href="#L1071">1071</a> }
<a class="jxr_linenumber" name="L1072" href="#L1072">1072</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1073" href="#L1073">1073</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1074" href="#L1074">1074</a> <em class="jxr_javadoccomment"> * Annotate fields in your class with {@code @Option} and picocli will initialize these fields when matching</em>
<a class="jxr_linenumber" name="L1075" href="#L1075">1075</a> <em class="jxr_javadoccomment"> * arguments are specified on the command line.</em>
<a class="jxr_linenumber" name="L1076" href="#L1076">1076</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1077" href="#L1077">1077</a> <em class="jxr_javadoccomment"> * For example:</em>
<a class="jxr_linenumber" name="L1078" href="#L1078">1078</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1079" href="#L1079">1079</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;import static picocli.CommandLine.*;</em>
<a class="jxr_linenumber" name="L1080" href="#L1080">1080</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1081" href="#L1081">1081</a> <em class="jxr_javadoccomment"> * public class MyClass {</em>
<a class="jxr_linenumber" name="L1082" href="#L1082">1082</a> <em class="jxr_javadoccomment"> * &amp;#064;Parameters(type = File.class, description = "Any number of input files")</em>
<a class="jxr_linenumber" name="L1083" href="#L1083">1083</a> <em class="jxr_javadoccomment"> * private List&amp;lt;File&amp;gt; files = new ArrayList&amp;lt;File&amp;gt;();</em>
<a class="jxr_linenumber" name="L1084" href="#L1084">1084</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1085" href="#L1085">1085</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-o", "--out" }, description = "Output file (default: print to console)")</em>
<a class="jxr_linenumber" name="L1086" href="#L1086">1086</a> <em class="jxr_javadoccomment"> * private File outputFile;</em>
<a class="jxr_linenumber" name="L1087" href="#L1087">1087</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1088" href="#L1088">1088</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-v", "--verbose"}, description = "Verbosely list files processed")</em>
<a class="jxr_linenumber" name="L1089" href="#L1089">1089</a> <em class="jxr_javadoccomment"> * private boolean verbose;</em>
<a class="jxr_linenumber" name="L1090" href="#L1090">1090</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1091" href="#L1091">1091</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-h", "--help", "-?", "-help"}, usageHelp = true, description = "Display this help and exit")</em>
<a class="jxr_linenumber" name="L1092" href="#L1092">1092</a> <em class="jxr_javadoccomment"> * private boolean help;</em>
<a class="jxr_linenumber" name="L1093" href="#L1093">1093</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1094" href="#L1094">1094</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-V", "--version"}, versionHelp = true, description = "Display version information and exit")</em>
<a class="jxr_linenumber" name="L1095" href="#L1095">1095</a> <em class="jxr_javadoccomment"> * private boolean version;</em>
<a class="jxr_linenumber" name="L1096" href="#L1096">1096</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L1097" href="#L1097">1097</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1098" href="#L1098">1098</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1099" href="#L1099">1099</a> <em class="jxr_javadoccomment"> * A field cannot be annotated with both {@code @Parameters} and {@code @Option} or a</em>
<a class="jxr_linenumber" name="L1100" href="#L1100">1100</a> <em class="jxr_javadoccomment"> * {@code ParameterException} is thrown.</em>
<a class="jxr_linenumber" name="L1101" href="#L1101">1101</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1102" href="#L1102">1102</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1103" href="#L1103">1103</a> @Retention(RetentionPolicy.RUNTIME)
<a class="jxr_linenumber" name="L1104" href="#L1104">1104</a> @Target(ElementType.FIELD)
<a class="jxr_linenumber" name="L1105" href="#L1105">1105</a> <strong class="jxr_keyword">public</strong> @<strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> {
<a class="jxr_linenumber" name="L1106" href="#L1106">1106</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1107" href="#L1107">1107</a> <em class="jxr_javadoccomment"> * One or more option names. At least one option name is required.</em>
<a class="jxr_linenumber" name="L1108" href="#L1108">1108</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1109" href="#L1109">1109</a> <em class="jxr_javadoccomment"> * Different environments have different conventions for naming options, but usually options have a prefix</em>
<a class="jxr_linenumber" name="L1110" href="#L1110">1110</a> <em class="jxr_javadoccomment"> * that sets them apart from parameters.</em>
<a class="jxr_linenumber" name="L1111" href="#L1111">1111</a> <em class="jxr_javadoccomment"> * Picocli supports all of the below styles. The default separator is {@code '='}, but this can be configured.</em>
<a class="jxr_linenumber" name="L1112" href="#L1112">1112</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1113" href="#L1113">1113</a> <em class="jxr_javadoccomment"> * &lt;b&gt;*nix&lt;/b&gt;</em>
<a class="jxr_linenumber" name="L1114" href="#L1114">1114</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1115" href="#L1115">1115</a> <em class="jxr_javadoccomment"> * In Unix and Linux, options have a short (single-character) name, a long name or both.</em>
<a class="jxr_linenumber" name="L1116" href="#L1116">1116</a> <em class="jxr_javadoccomment"> * Short options</em>
<a class="jxr_linenumber" name="L1117" href="#L1117">1117</a> <em class="jxr_javadoccomment"> * (&lt;a href="<a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html" target="alexandria_uri">http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html</a>#tag_12_02"&gt;POSIX</em>
<a class="jxr_linenumber" name="L1118" href="#L1118">1118</a> <em class="jxr_javadoccomment"> * style&lt;/a&gt; are single-character and are preceded by the {@code '-'} character, e.g., {@code `-v'}.</em>
<a class="jxr_linenumber" name="L1119" href="#L1119">1119</a> <em class="jxr_javadoccomment"> * &lt;a href="https://www.gnu.org/software/tar/manual/html_node/Long-Options.html"&gt;GNU-style&lt;/a&gt; long</em>
<a class="jxr_linenumber" name="L1120" href="#L1120">1120</a> <em class="jxr_javadoccomment"> * (or &lt;em&gt;mnemonic&lt;/em&gt;) options start with two dashes in a row, e.g., {@code `--file'}.</em>
<a class="jxr_linenumber" name="L1121" href="#L1121">1121</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;Picocli supports the POSIX convention that short options can be grouped, with the last option</em>
<a class="jxr_linenumber" name="L1122" href="#L1122">1122</a> <em class="jxr_javadoccomment"> * optionally taking a parameter, which may be attached to the option name or separated by a space or</em>
<a class="jxr_linenumber" name="L1123" href="#L1123">1123</a> <em class="jxr_javadoccomment"> * a {@code '='} character. The below examples are all equivalent:</em>
<a class="jxr_linenumber" name="L1124" href="#L1124">1124</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1125" href="#L1125">1125</a> <em class="jxr_javadoccomment"> * -xvfFILE</em>
<a class="jxr_linenumber" name="L1126" href="#L1126">1126</a> <em class="jxr_javadoccomment"> * -xvf FILE</em>
<a class="jxr_linenumber" name="L1127" href="#L1127">1127</a> <em class="jxr_javadoccomment"> * -xvf=FILE</em>
<a class="jxr_linenumber" name="L1128" href="#L1128">1128</a> <em class="jxr_javadoccomment"> * -xv --file FILE</em>
<a class="jxr_linenumber" name="L1129" href="#L1129">1129</a> <em class="jxr_javadoccomment"> * -xv --file=FILE</em>
<a class="jxr_linenumber" name="L1130" href="#L1130">1130</a> <em class="jxr_javadoccomment"> * -x -v --file FILE</em>
<a class="jxr_linenumber" name="L1131" href="#L1131">1131</a> <em class="jxr_javadoccomment"> * -x -v --file=FILE</em>
<a class="jxr_linenumber" name="L1132" href="#L1132">1132</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1133" href="#L1133">1133</a> <em class="jxr_javadoccomment"> * &lt;b&gt;DOS&lt;/b&gt;</em>
<a class="jxr_linenumber" name="L1134" href="#L1134">1134</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1135" href="#L1135">1135</a> <em class="jxr_javadoccomment"> * DOS options mostly have upper case single-character names and start with a single slash {@code '/'} character.</em>
<a class="jxr_linenumber" name="L1136" href="#L1136">1136</a> <em class="jxr_javadoccomment"> * Option parameters are separated by a {@code ':'} character. Options cannot be grouped together but</em>
<a class="jxr_linenumber" name="L1137" href="#L1137">1137</a> <em class="jxr_javadoccomment"> * must be specified separately. For example:</em>
<a class="jxr_linenumber" name="L1138" href="#L1138">1138</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1139" href="#L1139">1139</a> <em class="jxr_javadoccomment"> * DIR /S /A:D /T:C</em>
<a class="jxr_linenumber" name="L1140" href="#L1140">1140</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1141" href="#L1141">1141</a> <em class="jxr_javadoccomment"> * &lt;b&gt;PowerShell&lt;/b&gt;</em>
<a class="jxr_linenumber" name="L1142" href="#L1142">1142</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1143" href="#L1143">1143</a> <em class="jxr_javadoccomment"> * Windows PowerShell options generally are a word preceded by a single {@code '-'} character, e.g., {@code `-Help'}.</em>
<a class="jxr_linenumber" name="L1144" href="#L1144">1144</a> <em class="jxr_javadoccomment"> * Option parameters are separated by a space or by a {@code ':'} character.</em>
<a class="jxr_linenumber" name="L1145" href="#L1145">1145</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1146" href="#L1146">1146</a> <em class="jxr_javadoccomment"> * @return one or more option names</em>
<a class="jxr_linenumber" name="L1147" href="#L1147">1147</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1148" href="#L1148">1148</a> String[] names();
<a class="jxr_linenumber" name="L1149" href="#L1149">1149</a>
<a class="jxr_linenumber" name="L1150" href="#L1150">1150</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1151" href="#L1151">1151</a> <em class="jxr_javadoccomment"> * Indicates whether this option is required. By default this is false.</em>
<a class="jxr_linenumber" name="L1152" href="#L1152">1152</a> <em class="jxr_javadoccomment"> * If an option is required, but a user invokes the program without specifying the required option,</em>
<a class="jxr_linenumber" name="L1153" href="#L1153">1153</a> <em class="jxr_javadoccomment"> * a {@link MissingParameterException} is thrown from the {@link #parse(String...)} method.</em>
<a class="jxr_linenumber" name="L1154" href="#L1154">1154</a> <em class="jxr_javadoccomment"> * @return whether this option is required</em>
<a class="jxr_linenumber" name="L1155" href="#L1155">1155</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1156" href="#L1156">1156</a> <strong class="jxr_keyword">boolean</strong> required() <strong class="jxr_keyword">default</strong> false;
<a class="jxr_linenumber" name="L1157" href="#L1157">1157</a>
<a class="jxr_linenumber" name="L1158" href="#L1158">1158</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1159" href="#L1159">1159</a> <em class="jxr_javadoccomment"> * Set {@code help=true} if this option should disable validation of the remaining arguments:</em>
<a class="jxr_linenumber" name="L1160" href="#L1160">1160</a> <em class="jxr_javadoccomment"> * If the {@code help} option is specified, no error message is generated for missing required options.</em>
<a class="jxr_linenumber" name="L1161" href="#L1161">1161</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1162" href="#L1162">1162</a> <em class="jxr_javadoccomment"> * This attribute is useful for special options like help ({@code -h} and {@code --help} on unix,</em>
<a class="jxr_linenumber" name="L1163" href="#L1163">1163</a> <em class="jxr_javadoccomment"> * {@code -?} and {@code -Help} on Windows) or version ({@code -V} and {@code --version} on unix,</em>
<a class="jxr_linenumber" name="L1164" href="#L1164">1164</a> <em class="jxr_javadoccomment"> * {@code -Version} on Windows).</em>
<a class="jxr_linenumber" name="L1165" href="#L1165">1165</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1166" href="#L1166">1166</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1167" href="#L1167">1167</a> <em class="jxr_javadoccomment"> * Note that the {@link #parse(String...)} method will not print help documentation. It will only set</em>
<a class="jxr_linenumber" name="L1168" href="#L1168">1168</a> <em class="jxr_javadoccomment"> * the value of the annotated field. It is the responsibility of the caller to inspect the annotated fields</em>
<a class="jxr_linenumber" name="L1169" href="#L1169">1169</a> <em class="jxr_javadoccomment"> * and take the appropriate action.</em>
<a class="jxr_linenumber" name="L1170" href="#L1170">1170</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1171" href="#L1171">1171</a> <em class="jxr_javadoccomment"> * @return whether this option disables validation of the other arguments</em>
<a class="jxr_linenumber" name="L1172" href="#L1172">1172</a> <em class="jxr_javadoccomment"> * @deprecated Use {@link #usageHelp()} and {@link #versionHelp()} instead. See {@link #printHelpIfRequested(List, PrintStream, CommandLine.Help.Ansi)}</em>
<a class="jxr_linenumber" name="L1173" href="#L1173">1173</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1174" href="#L1174">1174</a> <strong class="jxr_keyword">boolean</strong> help() <strong class="jxr_keyword">default</strong> false;
<a class="jxr_linenumber" name="L1175" href="#L1175">1175</a>
<a class="jxr_linenumber" name="L1176" href="#L1176">1176</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1177" href="#L1177">1177</a> <em class="jxr_javadoccomment"> * Set {@code usageHelp=true} if this option allows the user to request usage help. If this option is</em>
<a class="jxr_linenumber" name="L1178" href="#L1178">1178</a> <em class="jxr_javadoccomment"> * specified on the command line, picocli will not validate the remaining arguments (so no "missing required</em>
<a class="jxr_linenumber" name="L1179" href="#L1179">1179</a> <em class="jxr_javadoccomment"> * option" errors) and the {@link CommandLine#isUsageHelpRequested()} method will return {@code true}.</em>
<a class="jxr_linenumber" name="L1180" href="#L1180">1180</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1181" href="#L1181">1181</a> <em class="jxr_javadoccomment"> * This attribute is useful for special options like help ({@code -h} and {@code --help} on unix,</em>
<a class="jxr_linenumber" name="L1182" href="#L1182">1182</a> <em class="jxr_javadoccomment"> * {@code -?} and {@code -Help} on Windows).</em>
<a class="jxr_linenumber" name="L1183" href="#L1183">1183</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1184" href="#L1184">1184</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1185" href="#L1185">1185</a> <em class="jxr_javadoccomment"> * Note that the {@link #parse(String...)} method will not print usage help documentation. It will only set</em>
<a class="jxr_linenumber" name="L1186" href="#L1186">1186</a> <em class="jxr_javadoccomment"> * the value of the annotated field. It is the responsibility of the caller to inspect the annotated fields</em>
<a class="jxr_linenumber" name="L1187" href="#L1187">1187</a> <em class="jxr_javadoccomment"> * and take the appropriate action.</em>
<a class="jxr_linenumber" name="L1188" href="#L1188">1188</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1189" href="#L1189">1189</a> <em class="jxr_javadoccomment"> * @return whether this option allows the user to request usage help</em>
<a class="jxr_linenumber" name="L1190" href="#L1190">1190</a> <em class="jxr_javadoccomment"> * @since 0.9.8</em>
<a class="jxr_linenumber" name="L1191" href="#L1191">1191</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1192" href="#L1192">1192</a> <strong class="jxr_keyword">boolean</strong> usageHelp() <strong class="jxr_keyword">default</strong> false;
<a class="jxr_linenumber" name="L1193" href="#L1193">1193</a>
<a class="jxr_linenumber" name="L1194" href="#L1194">1194</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1195" href="#L1195">1195</a> <em class="jxr_javadoccomment"> * Set {@code versionHelp=true} if this option allows the user to request version information. If this option is</em>
<a class="jxr_linenumber" name="L1196" href="#L1196">1196</a> <em class="jxr_javadoccomment"> * specified on the command line, picocli will not validate the remaining arguments (so no "missing required</em>
<a class="jxr_linenumber" name="L1197" href="#L1197">1197</a> <em class="jxr_javadoccomment"> * option" errors) and the {@link CommandLine#isVersionHelpRequested()} method will return {@code true}.</em>
<a class="jxr_linenumber" name="L1198" href="#L1198">1198</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1199" href="#L1199">1199</a> <em class="jxr_javadoccomment"> * This attribute is useful for special options like version ({@code -V} and {@code --version} on unix,</em>
<a class="jxr_linenumber" name="L1200" href="#L1200">1200</a> <em class="jxr_javadoccomment"> * {@code -Version} on Windows).</em>
<a class="jxr_linenumber" name="L1201" href="#L1201">1201</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1202" href="#L1202">1202</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1203" href="#L1203">1203</a> <em class="jxr_javadoccomment"> * Note that the {@link #parse(String...)} method will not print version information. It will only set</em>
<a class="jxr_linenumber" name="L1204" href="#L1204">1204</a> <em class="jxr_javadoccomment"> * the value of the annotated field. It is the responsibility of the caller to inspect the annotated fields</em>
<a class="jxr_linenumber" name="L1205" href="#L1205">1205</a> <em class="jxr_javadoccomment"> * and take the appropriate action.</em>
<a class="jxr_linenumber" name="L1206" href="#L1206">1206</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1207" href="#L1207">1207</a> <em class="jxr_javadoccomment"> * @return whether this option allows the user to request version information</em>
<a class="jxr_linenumber" name="L1208" href="#L1208">1208</a> <em class="jxr_javadoccomment"> * @since 0.9.8</em>
<a class="jxr_linenumber" name="L1209" href="#L1209">1209</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1210" href="#L1210">1210</a> <strong class="jxr_keyword">boolean</strong> versionHelp() <strong class="jxr_keyword">default</strong> false;
<a class="jxr_linenumber" name="L1211" href="#L1211">1211</a>
<a class="jxr_linenumber" name="L1212" href="#L1212">1212</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1213" href="#L1213">1213</a> <em class="jxr_javadoccomment"> * Description of this option, used when generating the usage documentation.</em>
<a class="jxr_linenumber" name="L1214" href="#L1214">1214</a> <em class="jxr_javadoccomment"> * @return the description of this option</em>
<a class="jxr_linenumber" name="L1215" href="#L1215">1215</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1216" href="#L1216">1216</a> String[] description() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1217" href="#L1217">1217</a>
<a class="jxr_linenumber" name="L1218" href="#L1218">1218</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1219" href="#L1219">1219</a> <em class="jxr_javadoccomment"> * Specifies the minimum number of required parameters and the maximum number of accepted parameters.</em>
<a class="jxr_linenumber" name="L1220" href="#L1220">1220</a> <em class="jxr_javadoccomment"> * If an option declares a positive arity, and the user specifies an insufficient number of parameters on the</em>
<a class="jxr_linenumber" name="L1221" href="#L1221">1221</a> <em class="jxr_javadoccomment"> * command line, a {@link MissingParameterException} is thrown by the {@link #parse(String...)} method.</em>
<a class="jxr_linenumber" name="L1222" href="#L1222">1222</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1223" href="#L1223">1223</a> <em class="jxr_javadoccomment"> * In many cases picocli can deduce the number of required parameters from the field's type.</em>
<a class="jxr_linenumber" name="L1224" href="#L1224">1224</a> <em class="jxr_javadoccomment"> * By default, flags (boolean options) have arity zero,</em>
<a class="jxr_linenumber" name="L1225" href="#L1225">1225</a> <em class="jxr_javadoccomment"> * and single-valued type fields (String, int, Integer, double, Double, File, Date, etc) have arity one.</em>
<a class="jxr_linenumber" name="L1226" href="#L1226">1226</a> <em class="jxr_javadoccomment"> * Generally, fields with types that cannot hold multiple values can omit the {@code arity} attribute.</em>
<a class="jxr_linenumber" name="L1227" href="#L1227">1227</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1228" href="#L1228">1228</a> <em class="jxr_javadoccomment"> * Fields used to capture options with arity two or higher should have a type that can hold multiple values,</em>
<a class="jxr_linenumber" name="L1229" href="#L1229">1229</a> <em class="jxr_javadoccomment"> * like arrays or Collections. See {@link #type()} for strongly-typed Collection fields.</em>
<a class="jxr_linenumber" name="L1230" href="#L1230">1230</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1231" href="#L1231">1231</a> <em class="jxr_javadoccomment"> * For example, if an option has 2 required parameters and any number of optional parameters,</em>
<a class="jxr_linenumber" name="L1232" href="#L1232">1232</a> <em class="jxr_javadoccomment"> * specify {@code @Option(names = "-example", arity = "2..*")}.</em>
<a class="jxr_linenumber" name="L1233" href="#L1233">1233</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1234" href="#L1234">1234</a> <em class="jxr_javadoccomment"> * &lt;b&gt;A note on boolean options&lt;/b&gt;</em>
<a class="jxr_linenumber" name="L1235" href="#L1235">1235</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1236" href="#L1236">1236</a> <em class="jxr_javadoccomment"> * By default picocli does not expect boolean options (also called "flags" or "switches") to have a parameter.</em>
<a class="jxr_linenumber" name="L1237" href="#L1237">1237</a> <em class="jxr_javadoccomment"> * You can make a boolean option take a required parameter by annotating your field with {@code arity="1"}.</em>
<a class="jxr_linenumber" name="L1238" href="#L1238">1238</a> <em class="jxr_javadoccomment"> * For example: &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1239" href="#L1239">1239</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;&amp;#064;Option(names = "-v", arity = "1") boolean verbose;&lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1240" href="#L1240">1240</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1241" href="#L1241">1241</a> <em class="jxr_javadoccomment"> * Because this boolean field is defined with arity 1, the user must specify either {@code &lt;program&gt; -v false}</em>
<a class="jxr_linenumber" name="L1242" href="#L1242">1242</a> <em class="jxr_javadoccomment"> * or {@code &lt;program&gt; -v true}</em>
<a class="jxr_linenumber" name="L1243" href="#L1243">1243</a> <em class="jxr_javadoccomment"> * on the command line, or a {@link MissingParameterException} is thrown by the {@link #parse(String...)}</em>
<a class="jxr_linenumber" name="L1244" href="#L1244">1244</a> <em class="jxr_javadoccomment"> * method.</em>
<a class="jxr_linenumber" name="L1245" href="#L1245">1245</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1246" href="#L1246">1246</a> <em class="jxr_javadoccomment"> * To make the boolean parameter possible but optional, define the field with {@code arity = "0..1"}.</em>
<a class="jxr_linenumber" name="L1247" href="#L1247">1247</a> <em class="jxr_javadoccomment"> * For example: &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1248" href="#L1248">1248</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;&amp;#064;Option(names="-v", arity="0..1") boolean verbose;&lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1249" href="#L1249">1249</a> <em class="jxr_javadoccomment"> * &lt;p&gt;This will accept any of the below without throwing an exception:&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1250" href="#L1250">1250</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1251" href="#L1251">1251</a> <em class="jxr_javadoccomment"> * -v</em>
<a class="jxr_linenumber" name="L1252" href="#L1252">1252</a> <em class="jxr_javadoccomment"> * -v true</em>
<a class="jxr_linenumber" name="L1253" href="#L1253">1253</a> <em class="jxr_javadoccomment"> * -v false</em>
<a class="jxr_linenumber" name="L1254" href="#L1254">1254</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1255" href="#L1255">1255</a> <em class="jxr_javadoccomment"> * @return how many arguments this option requires</em>
<a class="jxr_linenumber" name="L1256" href="#L1256">1256</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1257" href="#L1257">1257</a> String arity() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1258" href="#L1258">1258</a>
<a class="jxr_linenumber" name="L1259" href="#L1259">1259</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1260" href="#L1260">1260</a> <em class="jxr_javadoccomment"> * Specify a {@code paramLabel} for the option parameter to be used in the usage help message. If omitted,</em>
<a class="jxr_linenumber" name="L1261" href="#L1261">1261</a> <em class="jxr_javadoccomment"> * picocli uses the field name in fish brackets ({@code '&lt;'} and {@code '&gt;'}) by default. Example:</em>
<a class="jxr_linenumber" name="L1262" href="#L1262">1262</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;class Example {</em>
<a class="jxr_linenumber" name="L1263" href="#L1263">1263</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = {"-o", "--output"}, paramLabel="FILE", description="path of the output file")</em>
<a class="jxr_linenumber" name="L1264" href="#L1264">1264</a> <em class="jxr_javadoccomment"> * private File out;</em>
<a class="jxr_linenumber" name="L1265" href="#L1265">1265</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = {"-j", "--jobs"}, arity="0..1", description="Allow N jobs at once; infinite jobs with no arg.")</em>
<a class="jxr_linenumber" name="L1266" href="#L1266">1266</a> <em class="jxr_javadoccomment"> * private int maxJobs = -1;</em>
<a class="jxr_linenumber" name="L1267" href="#L1267">1267</a> <em class="jxr_javadoccomment"> * }&lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1268" href="#L1268">1268</a> <em class="jxr_javadoccomment"> * &lt;p&gt;By default, the above gives a usage help message like the following:&lt;/p&gt;&lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1269" href="#L1269">1269</a> <em class="jxr_javadoccomment"> * Usage: &amp;lt;main class&amp;gt; [OPTIONS]</em>
<a class="jxr_linenumber" name="L1270" href="#L1270">1270</a> <em class="jxr_javadoccomment"> * -o, --output FILE path of the output file</em>
<a class="jxr_linenumber" name="L1271" href="#L1271">1271</a> <em class="jxr_javadoccomment"> * -j, --jobs [&amp;lt;maxJobs&amp;gt;] Allow N jobs at once; infinite jobs with no arg.</em>
<a class="jxr_linenumber" name="L1272" href="#L1272">1272</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1273" href="#L1273">1273</a> <em class="jxr_javadoccomment"> * @return name of the option parameter used in the usage help message</em>
<a class="jxr_linenumber" name="L1274" href="#L1274">1274</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1275" href="#L1275">1275</a> String paramLabel() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1276" href="#L1276">1276</a>
<a class="jxr_linenumber" name="L1277" href="#L1277">1277</a> <em class="jxr_javadoccomment">/** &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1278" href="#L1278">1278</a> <em class="jxr_javadoccomment"> * Optionally specify a {@code type} to control exactly what Class the option parameter should be converted</em>
<a class="jxr_linenumber" name="L1279" href="#L1279">1279</a> <em class="jxr_javadoccomment"> * to. This may be useful when the field type is an interface or an abstract class. For example, a field can</em>
<a class="jxr_linenumber" name="L1280" href="#L1280">1280</a> <em class="jxr_javadoccomment"> * be declared to have type {@code java.lang.Number}, and annotating {@code @Option(type=Short.class)}</em>
<a class="jxr_linenumber" name="L1281" href="#L1281">1281</a> <em class="jxr_javadoccomment"> * ensures that the option parameter value is converted to a {@code Short} before setting the field value.</em>
<a class="jxr_linenumber" name="L1282" href="#L1282">1282</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1283" href="#L1283">1283</a> <em class="jxr_javadoccomment"> * For array fields whose &lt;em&gt;component&lt;/em&gt; type is an interface or abstract class, specify the concrete &lt;em&gt;component&lt;/em&gt; type.</em>
<a class="jxr_linenumber" name="L1284" href="#L1284">1284</a> <em class="jxr_javadoccomment"> * For example, a field with type {@code Number[]} may be annotated with {@code @Option(type=Short.class)}</em>
<a class="jxr_linenumber" name="L1285" href="#L1285">1285</a> <em class="jxr_javadoccomment"> * to ensure that option parameter values are converted to {@code Short} before adding an element to the array.</em>
<a class="jxr_linenumber" name="L1286" href="#L1286">1286</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1287" href="#L1287">1287</a> <em class="jxr_javadoccomment"> * Picocli will use the {@link ITypeConverter} that is</em>
<a class="jxr_linenumber" name="L1288" href="#L1288">1288</a> <em class="jxr_javadoccomment"> * {@linkplain #registerConverter(Class, ITypeConverter) registered} for the specified type to convert</em>
<a class="jxr_linenumber" name="L1289" href="#L1289">1289</a> <em class="jxr_javadoccomment"> * the raw String values before modifying the field value.</em>
<a class="jxr_linenumber" name="L1290" href="#L1290">1290</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1291" href="#L1291">1291</a> <em class="jxr_javadoccomment"> * Prior to 2.0, the {@code type} attribute was necessary for {@code Collection} and {@code Map} fields,</em>
<a class="jxr_linenumber" name="L1292" href="#L1292">1292</a> <em class="jxr_javadoccomment"> * but starting from 2.0 picocli will infer the component type from the generic type's type arguments.</em>
<a class="jxr_linenumber" name="L1293" href="#L1293">1293</a> <em class="jxr_javadoccomment"> * For example, for a field of type {@code Map&lt;TimeUnit, Long&gt;} picocli will know the option parameter</em>
<a class="jxr_linenumber" name="L1294" href="#L1294">1294</a> <em class="jxr_javadoccomment"> * should be split up in key=value pairs, where the key should be converted to a {@code java.util.concurrent.TimeUnit}</em>
<a class="jxr_linenumber" name="L1295" href="#L1295">1295</a> <em class="jxr_javadoccomment"> * enum value, and the value should be converted to a {@code Long}. No {@code @Option(type=...)} type attribute</em>
<a class="jxr_linenumber" name="L1296" href="#L1296">1296</a> <em class="jxr_javadoccomment"> * is required for this. For generic types with wildcards, picocli will take the specified upper or lower bound</em>
<a class="jxr_linenumber" name="L1297" href="#L1297">1297</a> <em class="jxr_javadoccomment"> * as the Class to convert to, unless the {@code @Option} annotation specifies an explicit {@code type} attribute.</em>
<a class="jxr_linenumber" name="L1298" href="#L1298">1298</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1299" href="#L1299">1299</a> <em class="jxr_javadoccomment"> * If the field type is a raw collection or a raw map, and you want it to contain other values than Strings,</em>
<a class="jxr_linenumber" name="L1300" href="#L1300">1300</a> <em class="jxr_javadoccomment"> * or if the generic type's type arguments are interfaces or abstract classes, you may</em>
<a class="jxr_linenumber" name="L1301" href="#L1301">1301</a> <em class="jxr_javadoccomment"> * specify a {@code type} attribute to control the Class that the option parameter should be converted to.</em>
<a class="jxr_linenumber" name="L1302" href="#L1302">1302</a> <em class="jxr_javadoccomment"> * @return the type(s) to convert the raw String values</em>
<a class="jxr_linenumber" name="L1303" href="#L1303">1303</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1304" href="#L1304">1304</a> Class&lt;?&gt;[] type() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1305" href="#L1305">1305</a>
<a class="jxr_linenumber" name="L1306" href="#L1306">1306</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1307" href="#L1307">1307</a> <em class="jxr_javadoccomment"> * Specify a regular expression to use to split option parameter values before applying them to the field.</em>
<a class="jxr_linenumber" name="L1308" href="#L1308">1308</a> <em class="jxr_javadoccomment"> * All elements resulting from the split are added to the array or Collection. Ignored for single-value fields.</em>
<a class="jxr_linenumber" name="L1309" href="#L1309">1309</a> <em class="jxr_javadoccomment"> * @return a regular expression to split option parameter values or {@code ""} if the value should not be split</em>
<a class="jxr_linenumber" name="L1310" href="#L1310">1310</a> <em class="jxr_javadoccomment"> * @see String#split(String)</em>
<a class="jxr_linenumber" name="L1311" href="#L1311">1311</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1312" href="#L1312">1312</a> String split() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1313" href="#L1313">1313</a>
<a class="jxr_linenumber" name="L1314" href="#L1314">1314</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1315" href="#L1315">1315</a> <em class="jxr_javadoccomment"> * Set {@code hidden=true} if this option should not be included in the usage documentation.</em>
<a class="jxr_linenumber" name="L1316" href="#L1316">1316</a> <em class="jxr_javadoccomment"> * @return whether this option should be excluded from the usage message</em>
<a class="jxr_linenumber" name="L1317" href="#L1317">1317</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1318" href="#L1318">1318</a> <strong class="jxr_keyword">boolean</strong> hidden() <strong class="jxr_keyword">default</strong> false;
<a class="jxr_linenumber" name="L1319" href="#L1319">1319</a> }
<a class="jxr_linenumber" name="L1320" href="#L1320">1320</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1321" href="#L1321">1321</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1322" href="#L1322">1322</a> <em class="jxr_javadoccomment"> * Fields annotated with {@code @Parameters} will be initialized with positional parameters. By specifying the</em>
<a class="jxr_linenumber" name="L1323" href="#L1323">1323</a> <em class="jxr_javadoccomment"> * {@link #index()} attribute you can pick which (or what range) of the positional parameters to apply. If no index</em>
<a class="jxr_linenumber" name="L1324" href="#L1324">1324</a> <em class="jxr_javadoccomment"> * is specified, the field will get all positional parameters (so it should be an array or a collection).</em>
<a class="jxr_linenumber" name="L1325" href="#L1325">1325</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1326" href="#L1326">1326</a> <em class="jxr_javadoccomment"> * When parsing the command line arguments, picocli first tries to match arguments to {@link Option Options}.</em>
<a class="jxr_linenumber" name="L1327" href="#L1327">1327</a> <em class="jxr_javadoccomment"> * Positional parameters are the arguments that follow the options, or the arguments that follow a "--" (double</em>
<a class="jxr_linenumber" name="L1328" href="#L1328">1328</a> <em class="jxr_javadoccomment"> * dash) argument on the command line.</em>
<a class="jxr_linenumber" name="L1329" href="#L1329">1329</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1330" href="#L1330">1330</a> <em class="jxr_javadoccomment"> * For example:</em>
<a class="jxr_linenumber" name="L1331" href="#L1331">1331</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1332" href="#L1332">1332</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;import static picocli.CommandLine.*;</em>
<a class="jxr_linenumber" name="L1333" href="#L1333">1333</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1334" href="#L1334">1334</a> <em class="jxr_javadoccomment"> * public class MyCalcParameters {</em>
<a class="jxr_linenumber" name="L1335" href="#L1335">1335</a> <em class="jxr_javadoccomment"> * &amp;#064;Parameters(type = BigDecimal.class, description = "Any number of input numbers")</em>
<a class="jxr_linenumber" name="L1336" href="#L1336">1336</a> <em class="jxr_javadoccomment"> * private List&amp;lt;BigDecimal&amp;gt; files = new ArrayList&amp;lt;BigDecimal&amp;gt;();</em>
<a class="jxr_linenumber" name="L1337" href="#L1337">1337</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1338" href="#L1338">1338</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-h", "--help", "-?", "-help"}, help = true, description = "Display this help and exit")</em>
<a class="jxr_linenumber" name="L1339" href="#L1339">1339</a> <em class="jxr_javadoccomment"> * private boolean help;</em>
<a class="jxr_linenumber" name="L1340" href="#L1340">1340</a> <em class="jxr_javadoccomment"> * }</em>
<a class="jxr_linenumber" name="L1341" href="#L1341">1341</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1342" href="#L1342">1342</a> <em class="jxr_javadoccomment"> * A field cannot be annotated with both {@code @Parameters} and {@code @Option} or a {@code ParameterException}</em>
<a class="jxr_linenumber" name="L1343" href="#L1343">1343</a> <em class="jxr_javadoccomment"> * is thrown.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1344" href="#L1344">1344</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1345" href="#L1345">1345</a> @Retention(RetentionPolicy.RUNTIME)
<a class="jxr_linenumber" name="L1346" href="#L1346">1346</a> @Target(ElementType.FIELD)
<a class="jxr_linenumber" name="L1347" href="#L1347">1347</a> <strong class="jxr_keyword">public</strong> @<strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Parameters</a> {
<a class="jxr_linenumber" name="L1348" href="#L1348">1348</a> <em class="jxr_javadoccomment">/** Specify an index ("0", or "1", etc.) to pick which of the command line arguments should be assigned to this</em>
<a class="jxr_linenumber" name="L1349" href="#L1349">1349</a> <em class="jxr_javadoccomment"> * field. For array or Collection fields, you can also specify an index range ("0..3", or "2..*", etc.) to assign</em>
<a class="jxr_linenumber" name="L1350" href="#L1350">1350</a> <em class="jxr_javadoccomment"> * a subset of the command line arguments to this field. The default is "*", meaning all command line arguments.</em>
<a class="jxr_linenumber" name="L1351" href="#L1351">1351</a> <em class="jxr_javadoccomment"> * @return an index or range specifying which of the command line arguments should be assigned to this field</em>
<a class="jxr_linenumber" name="L1352" href="#L1352">1352</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1353" href="#L1353">1353</a> String index() <strong class="jxr_keyword">default</strong> <span class="jxr_string">"*"</span>;
<a class="jxr_linenumber" name="L1354" href="#L1354">1354</a>
<a class="jxr_linenumber" name="L1355" href="#L1355">1355</a> <em class="jxr_javadoccomment">/** Description of the parameter(s), used when generating the usage documentation.</em>
<a class="jxr_linenumber" name="L1356" href="#L1356">1356</a> <em class="jxr_javadoccomment"> * @return the description of the parameter(s)</em>
<a class="jxr_linenumber" name="L1357" href="#L1357">1357</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1358" href="#L1358">1358</a> String[] description() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1359" href="#L1359">1359</a>
<a class="jxr_linenumber" name="L1360" href="#L1360">1360</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1361" href="#L1361">1361</a> <em class="jxr_javadoccomment"> * Specifies the minimum number of required parameters and the maximum number of accepted parameters. If a</em>
<a class="jxr_linenumber" name="L1362" href="#L1362">1362</a> <em class="jxr_javadoccomment"> * positive arity is declared, and the user specifies an insufficient number of parameters on the command line,</em>
<a class="jxr_linenumber" name="L1363" href="#L1363">1363</a> <em class="jxr_javadoccomment"> * {@link MissingParameterException} is thrown by the {@link #parse(String...)} method.</em>
<a class="jxr_linenumber" name="L1364" href="#L1364">1364</a> <em class="jxr_javadoccomment"> * &lt;p&gt;The default depends on the type of the parameter: booleans require no parameters, arrays and Collections</em>
<a class="jxr_linenumber" name="L1365" href="#L1365">1365</a> <em class="jxr_javadoccomment"> * accept zero to any number of parameters, and any other type accepts one parameter.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1366" href="#L1366">1366</a> <em class="jxr_javadoccomment"> * @return the range of minimum and maximum parameters accepted by this command</em>
<a class="jxr_linenumber" name="L1367" href="#L1367">1367</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1368" href="#L1368">1368</a> String arity() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1369" href="#L1369">1369</a>
<a class="jxr_linenumber" name="L1370" href="#L1370">1370</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1371" href="#L1371">1371</a> <em class="jxr_javadoccomment"> * Specify a {@code paramLabel} for the parameter to be used in the usage help message. If omitted,</em>
<a class="jxr_linenumber" name="L1372" href="#L1372">1372</a> <em class="jxr_javadoccomment"> * picocli uses the field name in fish brackets ({@code '&lt;'} and {@code '&gt;'}) by default. Example:</em>
<a class="jxr_linenumber" name="L1373" href="#L1373">1373</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;class Example {</em>
<a class="jxr_linenumber" name="L1374" href="#L1374">1374</a> <em class="jxr_javadoccomment"> * &amp;#064;Parameters(paramLabel="FILE", description="path of the input FILE(s)")</em>
<a class="jxr_linenumber" name="L1375" href="#L1375">1375</a> <em class="jxr_javadoccomment"> * private File[] inputFiles;</em>
<a class="jxr_linenumber" name="L1376" href="#L1376">1376</a> <em class="jxr_javadoccomment"> * }&lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1377" href="#L1377">1377</a> <em class="jxr_javadoccomment"> * &lt;p&gt;By default, the above gives a usage help message like the following:&lt;/p&gt;&lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1378" href="#L1378">1378</a> <em class="jxr_javadoccomment"> * Usage: &amp;lt;main class&amp;gt; [FILE...]</em>
<a class="jxr_linenumber" name="L1379" href="#L1379">1379</a> <em class="jxr_javadoccomment"> * [FILE...] path of the input FILE(s)</em>
<a class="jxr_linenumber" name="L1380" href="#L1380">1380</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1381" href="#L1381">1381</a> <em class="jxr_javadoccomment"> * @return name of the positional parameter used in the usage help message</em>
<a class="jxr_linenumber" name="L1382" href="#L1382">1382</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1383" href="#L1383">1383</a> String paramLabel() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1384" href="#L1384">1384</a>
<a class="jxr_linenumber" name="L1385" href="#L1385">1385</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1386" href="#L1386">1386</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1387" href="#L1387">1387</a> <em class="jxr_javadoccomment"> * Optionally specify a {@code type} to control exactly what Class the positional parameter should be converted</em>
<a class="jxr_linenumber" name="L1388" href="#L1388">1388</a> <em class="jxr_javadoccomment"> * to. This may be useful when the field type is an interface or an abstract class. For example, a field can</em>
<a class="jxr_linenumber" name="L1389" href="#L1389">1389</a> <em class="jxr_javadoccomment"> * be declared to have type {@code java.lang.Number}, and annotating {@code @Parameters(type=Short.class)}</em>
<a class="jxr_linenumber" name="L1390" href="#L1390">1390</a> <em class="jxr_javadoccomment"> * ensures that the positional parameter value is converted to a {@code Short} before setting the field value.</em>
<a class="jxr_linenumber" name="L1391" href="#L1391">1391</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1392" href="#L1392">1392</a> <em class="jxr_javadoccomment"> * For array fields whose &lt;em&gt;component&lt;/em&gt; type is an interface or abstract class, specify the concrete &lt;em&gt;component&lt;/em&gt; type.</em>
<a class="jxr_linenumber" name="L1393" href="#L1393">1393</a> <em class="jxr_javadoccomment"> * For example, a field with type {@code Number[]} may be annotated with {@code @Parameters(type=Short.class)}</em>
<a class="jxr_linenumber" name="L1394" href="#L1394">1394</a> <em class="jxr_javadoccomment"> * to ensure that positional parameter values are converted to {@code Short} before adding an element to the array.</em>
<a class="jxr_linenumber" name="L1395" href="#L1395">1395</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1396" href="#L1396">1396</a> <em class="jxr_javadoccomment"> * Picocli will use the {@link ITypeConverter} that is</em>
<a class="jxr_linenumber" name="L1397" href="#L1397">1397</a> <em class="jxr_javadoccomment"> * {@linkplain #registerConverter(Class, ITypeConverter) registered} for the specified type to convert</em>
<a class="jxr_linenumber" name="L1398" href="#L1398">1398</a> <em class="jxr_javadoccomment"> * the raw String values before modifying the field value.</em>
<a class="jxr_linenumber" name="L1399" href="#L1399">1399</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1400" href="#L1400">1400</a> <em class="jxr_javadoccomment"> * Prior to 2.0, the {@code type} attribute was necessary for {@code Collection} and {@code Map} fields,</em>
<a class="jxr_linenumber" name="L1401" href="#L1401">1401</a> <em class="jxr_javadoccomment"> * but starting from 2.0 picocli will infer the component type from the generic type's type arguments.</em>
<a class="jxr_linenumber" name="L1402" href="#L1402">1402</a> <em class="jxr_javadoccomment"> * For example, for a field of type {@code Map&lt;TimeUnit, Long&gt;} picocli will know the positional parameter</em>
<a class="jxr_linenumber" name="L1403" href="#L1403">1403</a> <em class="jxr_javadoccomment"> * should be split up in key=value pairs, where the key should be converted to a {@code java.util.concurrent.TimeUnit}</em>
<a class="jxr_linenumber" name="L1404" href="#L1404">1404</a> <em class="jxr_javadoccomment"> * enum value, and the value should be converted to a {@code Long}. No {@code @Parameters(type=...)} type attribute</em>
<a class="jxr_linenumber" name="L1405" href="#L1405">1405</a> <em class="jxr_javadoccomment"> * is required for this. For generic types with wildcards, picocli will take the specified upper or lower bound</em>
<a class="jxr_linenumber" name="L1406" href="#L1406">1406</a> <em class="jxr_javadoccomment"> * as the Class to convert to, unless the {@code @Parameters} annotation specifies an explicit {@code type} attribute.</em>
<a class="jxr_linenumber" name="L1407" href="#L1407">1407</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1408" href="#L1408">1408</a> <em class="jxr_javadoccomment"> * If the field type is a raw collection or a raw map, and you want it to contain other values than Strings,</em>
<a class="jxr_linenumber" name="L1409" href="#L1409">1409</a> <em class="jxr_javadoccomment"> * or if the generic type's type arguments are interfaces or abstract classes, you may</em>
<a class="jxr_linenumber" name="L1410" href="#L1410">1410</a> <em class="jxr_javadoccomment"> * specify a {@code type} attribute to control the Class that the positional parameter should be converted to.</em>
<a class="jxr_linenumber" name="L1411" href="#L1411">1411</a> <em class="jxr_javadoccomment"> * @return the type(s) to convert the raw String values</em>
<a class="jxr_linenumber" name="L1412" href="#L1412">1412</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1413" href="#L1413">1413</a> Class&lt;?&gt;[] type() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1414" href="#L1414">1414</a>
<a class="jxr_linenumber" name="L1415" href="#L1415">1415</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1416" href="#L1416">1416</a> <em class="jxr_javadoccomment"> * Specify a regular expression to use to split positional parameter values before applying them to the field.</em>
<a class="jxr_linenumber" name="L1417" href="#L1417">1417</a> <em class="jxr_javadoccomment"> * All elements resulting from the split are added to the array or Collection. Ignored for single-value fields.</em>
<a class="jxr_linenumber" name="L1418" href="#L1418">1418</a> <em class="jxr_javadoccomment"> * @return a regular expression to split operand values or {@code ""} if the value should not be split</em>
<a class="jxr_linenumber" name="L1419" href="#L1419">1419</a> <em class="jxr_javadoccomment"> * @see String#split(String)</em>
<a class="jxr_linenumber" name="L1420" href="#L1420">1420</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1421" href="#L1421">1421</a> String split() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1422" href="#L1422">1422</a>
<a class="jxr_linenumber" name="L1423" href="#L1423">1423</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1424" href="#L1424">1424</a> <em class="jxr_javadoccomment"> * Set {@code hidden=true} if this parameter should not be included in the usage message.</em>
<a class="jxr_linenumber" name="L1425" href="#L1425">1425</a> <em class="jxr_javadoccomment"> * @return whether this parameter should be excluded from the usage message</em>
<a class="jxr_linenumber" name="L1426" href="#L1426">1426</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1427" href="#L1427">1427</a> <strong class="jxr_keyword">boolean</strong> hidden() <strong class="jxr_keyword">default</strong> false;
<a class="jxr_linenumber" name="L1428" href="#L1428">1428</a> }
<a class="jxr_linenumber" name="L1429" href="#L1429">1429</a>
<a class="jxr_linenumber" name="L1430" href="#L1430">1430</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1431" href="#L1431">1431</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Annotate your class with {@code @Command} when you want more control over the format of the generated help</em>
<a class="jxr_linenumber" name="L1432" href="#L1432">1432</a> <em class="jxr_javadoccomment"> * message.</em>
<a class="jxr_linenumber" name="L1433" href="#L1433">1433</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1434" href="#L1434">1434</a> <em class="jxr_javadoccomment"> * &amp;#064;Command(name = "Encrypt",</em>
<a class="jxr_linenumber" name="L1435" href="#L1435">1435</a> <em class="jxr_javadoccomment"> * description = "Encrypt FILE(s), or standard input, to standard output or to the output file.",</em>
<a class="jxr_linenumber" name="L1436" href="#L1436">1436</a> <em class="jxr_javadoccomment"> * footer = "Copyright (c) 2017")</em>
<a class="jxr_linenumber" name="L1437" href="#L1437">1437</a> <em class="jxr_javadoccomment"> * public class Encrypt {</em>
<a class="jxr_linenumber" name="L1438" href="#L1438">1438</a> <em class="jxr_javadoccomment"> * &amp;#064;Parameters(paramLabel = "FILE", type = File.class, description = "Any number of input files")</em>
<a class="jxr_linenumber" name="L1439" href="#L1439">1439</a> <em class="jxr_javadoccomment"> * private List&amp;lt;File&amp;gt; files = new ArrayList&amp;lt;File&amp;gt;();</em>
<a class="jxr_linenumber" name="L1440" href="#L1440">1440</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1441" href="#L1441">1441</a> <em class="jxr_javadoccomment"> * &amp;#064;Option(names = { "-o", "--out" }, description = "Output file (default: print to console)")</em>
<a class="jxr_linenumber" name="L1442" href="#L1442">1442</a> <em class="jxr_javadoccomment"> * private File outputFile;</em>
<a class="jxr_linenumber" name="L1443" href="#L1443">1443</a> <em class="jxr_javadoccomment"> * }&lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1444" href="#L1444">1444</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1445" href="#L1445">1445</a> <em class="jxr_javadoccomment"> * The structure of a help message looks like this:</em>
<a class="jxr_linenumber" name="L1446" href="#L1446">1446</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;ul&gt;</em>
<a class="jxr_linenumber" name="L1447" href="#L1447">1447</a> <em class="jxr_javadoccomment"> * &lt;li&gt;[header]&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1448" href="#L1448">1448</a> <em class="jxr_javadoccomment"> * &lt;li&gt;[synopsis]: {@code Usage: &lt;commandName&gt; [OPTIONS] [FILE...]}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1449" href="#L1449">1449</a> <em class="jxr_javadoccomment"> * &lt;li&gt;[description]&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1450" href="#L1450">1450</a> <em class="jxr_javadoccomment"> * &lt;li&gt;[parameter list]: {@code [FILE...] Any number of input files}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1451" href="#L1451">1451</a> <em class="jxr_javadoccomment"> * &lt;li&gt;[option list]: {@code -h, --help prints this help message and exits}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1452" href="#L1452">1452</a> <em class="jxr_javadoccomment"> * &lt;li&gt;[footer]&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1453" href="#L1453">1453</a> <em class="jxr_javadoccomment"> * &lt;/ul&gt; */</em>
<a class="jxr_linenumber" name="L1454" href="#L1454">1454</a> @Retention(RetentionPolicy.RUNTIME)
<a class="jxr_linenumber" name="L1455" href="#L1455">1455</a> @Target({ElementType.TYPE, ElementType.LOCAL_VARIABLE, ElementType.PACKAGE})
<a class="jxr_linenumber" name="L1456" href="#L1456">1456</a> <strong class="jxr_keyword">public</strong> @<strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Command</a> {
<a class="jxr_linenumber" name="L1457" href="#L1457">1457</a> <em class="jxr_javadoccomment">/** Program name to show in the synopsis. If omitted, {@code "&lt;main class&gt;"} is used.</em>
<a class="jxr_linenumber" name="L1458" href="#L1458">1458</a> <em class="jxr_javadoccomment"> * For {@linkplain #subcommands() declaratively added} subcommands, this attribute is also used</em>
<a class="jxr_linenumber" name="L1459" href="#L1459">1459</a> <em class="jxr_javadoccomment"> * by the parser to recognize subcommands in the command line arguments.</em>
<a class="jxr_linenumber" name="L1460" href="#L1460">1460</a> <em class="jxr_javadoccomment"> * @return the program name to show in the synopsis</em>
<a class="jxr_linenumber" name="L1461" href="#L1461">1461</a> <em class="jxr_javadoccomment"> * @see Help#commandName */</em>
<a class="jxr_linenumber" name="L1462" href="#L1462">1462</a> String name() <strong class="jxr_keyword">default</strong> <span class="jxr_string">"&lt;main class&gt;"</span>;
<a class="jxr_linenumber" name="L1463" href="#L1463">1463</a>
<a class="jxr_linenumber" name="L1464" href="#L1464">1464</a> <em class="jxr_javadoccomment">/** A list of classes to instantiate and register as subcommands. When registering subcommands declaratively</em>
<a class="jxr_linenumber" name="L1465" href="#L1465">1465</a> <em class="jxr_javadoccomment"> * like this, you don't need to call the {@link CommandLine#addSubcommand(String, Object)} method. For example, this:</em>
<a class="jxr_linenumber" name="L1466" href="#L1466">1466</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1467" href="#L1467">1467</a> <em class="jxr_javadoccomment"> * &amp;#064;Command(subcommands = {</em>
<a class="jxr_linenumber" name="L1468" href="#L1468">1468</a> <em class="jxr_javadoccomment"> * GitStatus.class,</em>
<a class="jxr_linenumber" name="L1469" href="#L1469">1469</a> <em class="jxr_javadoccomment"> * GitCommit.class,</em>
<a class="jxr_linenumber" name="L1470" href="#L1470">1470</a> <em class="jxr_javadoccomment"> * GitBranch.class })</em>
<a class="jxr_linenumber" name="L1471" href="#L1471">1471</a> <em class="jxr_javadoccomment"> * public class Git { ... }</em>
<a class="jxr_linenumber" name="L1472" href="#L1472">1472</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1473" href="#L1473">1473</a> <em class="jxr_javadoccomment"> * CommandLine commandLine = new CommandLine(new Git());</em>
<a class="jxr_linenumber" name="L1474" href="#L1474">1474</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt; is equivalent to this:</em>
<a class="jxr_linenumber" name="L1475" href="#L1475">1475</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1476" href="#L1476">1476</a> <em class="jxr_javadoccomment"> * // alternative: programmatically add subcommands.</em>
<a class="jxr_linenumber" name="L1477" href="#L1477">1477</a> <em class="jxr_javadoccomment"> * // NOTE: in this case there should be no `subcommands` attribute on the @Command annotation.</em>
<a class="jxr_linenumber" name="L1478" href="#L1478">1478</a> <em class="jxr_javadoccomment"> * &amp;#064;Command public class Git { ... }</em>
<a class="jxr_linenumber" name="L1479" href="#L1479">1479</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1480" href="#L1480">1480</a> <em class="jxr_javadoccomment"> * CommandLine commandLine = new CommandLine(new Git())</em>
<a class="jxr_linenumber" name="L1481" href="#L1481">1481</a> <em class="jxr_javadoccomment"> * .addSubcommand("status", new GitStatus())</em>
<a class="jxr_linenumber" name="L1482" href="#L1482">1482</a> <em class="jxr_javadoccomment"> * .addSubcommand("commit", new GitCommit())</em>
<a class="jxr_linenumber" name="L1483" href="#L1483">1483</a> <em class="jxr_javadoccomment"> * .addSubcommand("branch", new GitBranch());</em>
<a class="jxr_linenumber" name="L1484" href="#L1484">1484</a> <em class="jxr_javadoccomment"> * &lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1485" href="#L1485">1485</a> <em class="jxr_javadoccomment"> * @return the declaratively registered subcommands of this command, or an empty array if none</em>
<a class="jxr_linenumber" name="L1486" href="#L1486">1486</a> <em class="jxr_javadoccomment"> * @see CommandLine#addSubcommand(String, Object)</em>
<a class="jxr_linenumber" name="L1487" href="#L1487">1487</a> <em class="jxr_javadoccomment"> * @since 0.9.8</em>
<a class="jxr_linenumber" name="L1488" href="#L1488">1488</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1489" href="#L1489">1489</a> Class&lt;?&gt;[] subcommands() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1490" href="#L1490">1490</a>
<a class="jxr_linenumber" name="L1491" href="#L1491">1491</a> <em class="jxr_javadoccomment">/** String that separates options from option parameters. Default is {@code "="}. Spaces are also accepted.</em>
<a class="jxr_linenumber" name="L1492" href="#L1492">1492</a> <em class="jxr_javadoccomment"> * @return the string that separates options from option parameters, used both when parsing and when generating usage help</em>
<a class="jxr_linenumber" name="L1493" href="#L1493">1493</a> <em class="jxr_javadoccomment"> * @see Help#separator</em>
<a class="jxr_linenumber" name="L1494" href="#L1494">1494</a> <em class="jxr_javadoccomment"> * @see CommandLine#setSeparator(String) */</em>
<a class="jxr_linenumber" name="L1495" href="#L1495">1495</a> String separator() <strong class="jxr_keyword">default</strong> <span class="jxr_string">"="</span>;
<a class="jxr_linenumber" name="L1496" href="#L1496">1496</a>
<a class="jxr_linenumber" name="L1497" href="#L1497">1497</a> <em class="jxr_javadoccomment">/** Version information for this command, to print to the console when the user specifies an</em>
<a class="jxr_linenumber" name="L1498" href="#L1498">1498</a> <em class="jxr_javadoccomment"> * {@linkplain Option#versionHelp() option} to request version help. This is not part of the usage help message.</em>
<a class="jxr_linenumber" name="L1499" href="#L1499">1499</a> <em class="jxr_javadoccomment"> *</em>
<a class="jxr_linenumber" name="L1500" href="#L1500">1500</a> <em class="jxr_javadoccomment"> * @return a string or an array of strings with version information about this command.</em>
<a class="jxr_linenumber" name="L1501" href="#L1501">1501</a> <em class="jxr_javadoccomment"> * @since 0.9.8</em>
<a class="jxr_linenumber" name="L1502" href="#L1502">1502</a> <em class="jxr_javadoccomment"> * @see CommandLine#printVersionHelp(PrintStream)</em>
<a class="jxr_linenumber" name="L1503" href="#L1503">1503</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1504" href="#L1504">1504</a> String[] version() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1505" href="#L1505">1505</a>
<a class="jxr_linenumber" name="L1506" href="#L1506">1506</a> <em class="jxr_javadoccomment">/** Set the heading preceding the header section. May contain embedded {@linkplain java.util.Formatter format specifiers}.</em>
<a class="jxr_linenumber" name="L1507" href="#L1507">1507</a> <em class="jxr_javadoccomment"> * @return the heading preceding the header section</em>
<a class="jxr_linenumber" name="L1508" href="#L1508">1508</a> <em class="jxr_javadoccomment"> * @see Help#headerHeading(Object...) */</em>
<a class="jxr_linenumber" name="L1509" href="#L1509">1509</a> String headerHeading() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1510" href="#L1510">1510</a>
<a class="jxr_linenumber" name="L1511" href="#L1511">1511</a> <em class="jxr_javadoccomment">/** Optional summary description of the command, shown before the synopsis.</em>
<a class="jxr_linenumber" name="L1512" href="#L1512">1512</a> <em class="jxr_javadoccomment"> * @return summary description of the command</em>
<a class="jxr_linenumber" name="L1513" href="#L1513">1513</a> <em class="jxr_javadoccomment"> * @see Help#header</em>
<a class="jxr_linenumber" name="L1514" href="#L1514">1514</a> <em class="jxr_javadoccomment"> * @see Help#header(Object...) */</em>
<a class="jxr_linenumber" name="L1515" href="#L1515">1515</a> String[] header() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1516" href="#L1516">1516</a>
<a class="jxr_linenumber" name="L1517" href="#L1517">1517</a> <em class="jxr_javadoccomment">/** Set the heading preceding the synopsis text. May contain embedded</em>
<a class="jxr_linenumber" name="L1518" href="#L1518">1518</a> <em class="jxr_javadoccomment"> * {@linkplain java.util.Formatter format specifiers}. The default heading is {@code "Usage: "} (without a line</em>
<a class="jxr_linenumber" name="L1519" href="#L1519">1519</a> <em class="jxr_javadoccomment"> * break between the heading and the synopsis text).</em>
<a class="jxr_linenumber" name="L1520" href="#L1520">1520</a> <em class="jxr_javadoccomment"> * @return the heading preceding the synopsis text</em>
<a class="jxr_linenumber" name="L1521" href="#L1521">1521</a> <em class="jxr_javadoccomment"> * @see Help#synopsisHeading(Object...) */</em>
<a class="jxr_linenumber" name="L1522" href="#L1522">1522</a> String synopsisHeading() <strong class="jxr_keyword">default</strong> <span class="jxr_string">"Usage: "</span>;
<a class="jxr_linenumber" name="L1523" href="#L1523">1523</a>
<a class="jxr_linenumber" name="L1524" href="#L1524">1524</a> <em class="jxr_javadoccomment">/** Specify {@code true} to generate an abbreviated synopsis like {@code "&lt;main&gt; [OPTIONS] [PARAMETERS...]"}.</em>
<a class="jxr_linenumber" name="L1525" href="#L1525">1525</a> <em class="jxr_javadoccomment"> * By default, a detailed synopsis with individual option names and parameters is generated.</em>
<a class="jxr_linenumber" name="L1526" href="#L1526">1526</a> <em class="jxr_javadoccomment"> * @return whether the synopsis should be abbreviated</em>
<a class="jxr_linenumber" name="L1527" href="#L1527">1527</a> <em class="jxr_javadoccomment"> * @see Help#abbreviateSynopsis</em>
<a class="jxr_linenumber" name="L1528" href="#L1528">1528</a> <em class="jxr_javadoccomment"> * @see Help#abbreviatedSynopsis()</em>
<a class="jxr_linenumber" name="L1529" href="#L1529">1529</a> <em class="jxr_javadoccomment"> * @see Help#detailedSynopsis(Comparator, boolean) */</em>
<a class="jxr_linenumber" name="L1530" href="#L1530">1530</a> <strong class="jxr_keyword">boolean</strong> abbreviateSynopsis() <strong class="jxr_keyword">default</strong> false;
<a class="jxr_linenumber" name="L1531" href="#L1531">1531</a>
<a class="jxr_linenumber" name="L1532" href="#L1532">1532</a> <em class="jxr_javadoccomment">/** Specify one or more custom synopsis lines to display instead of an auto-generated synopsis.</em>
<a class="jxr_linenumber" name="L1533" href="#L1533">1533</a> <em class="jxr_javadoccomment"> * @return custom synopsis text to replace the auto-generated synopsis</em>
<a class="jxr_linenumber" name="L1534" href="#L1534">1534</a> <em class="jxr_javadoccomment"> * @see Help#customSynopsis</em>
<a class="jxr_linenumber" name="L1535" href="#L1535">1535</a> <em class="jxr_javadoccomment"> * @see Help#customSynopsis(Object...) */</em>
<a class="jxr_linenumber" name="L1536" href="#L1536">1536</a> String[] customSynopsis() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1537" href="#L1537">1537</a>
<a class="jxr_linenumber" name="L1538" href="#L1538">1538</a> <em class="jxr_javadoccomment">/** Set the heading preceding the description section. May contain embedded {@linkplain java.util.Formatter format specifiers}.</em>
<a class="jxr_linenumber" name="L1539" href="#L1539">1539</a> <em class="jxr_javadoccomment"> * @return the heading preceding the description section</em>
<a class="jxr_linenumber" name="L1540" href="#L1540">1540</a> <em class="jxr_javadoccomment"> * @see Help#descriptionHeading(Object...) */</em>
<a class="jxr_linenumber" name="L1541" href="#L1541">1541</a> String descriptionHeading() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1542" href="#L1542">1542</a>
<a class="jxr_linenumber" name="L1543" href="#L1543">1543</a> <em class="jxr_javadoccomment">/** Optional text to display between the synopsis line(s) and the list of options.</em>
<a class="jxr_linenumber" name="L1544" href="#L1544">1544</a> <em class="jxr_javadoccomment"> * @return description of this command</em>
<a class="jxr_linenumber" name="L1545" href="#L1545">1545</a> <em class="jxr_javadoccomment"> * @see Help#description</em>
<a class="jxr_linenumber" name="L1546" href="#L1546">1546</a> <em class="jxr_javadoccomment"> * @see Help#description(Object...) */</em>
<a class="jxr_linenumber" name="L1547" href="#L1547">1547</a> String[] description() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1548" href="#L1548">1548</a>
<a class="jxr_linenumber" name="L1549" href="#L1549">1549</a> <em class="jxr_javadoccomment">/** Set the heading preceding the parameters list. May contain embedded {@linkplain java.util.Formatter format specifiers}.</em>
<a class="jxr_linenumber" name="L1550" href="#L1550">1550</a> <em class="jxr_javadoccomment"> * @return the heading preceding the parameters list</em>
<a class="jxr_linenumber" name="L1551" href="#L1551">1551</a> <em class="jxr_javadoccomment"> * @see Help#parameterListHeading(Object...) */</em>
<a class="jxr_linenumber" name="L1552" href="#L1552">1552</a> String parameterListHeading() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1553" href="#L1553">1553</a>
<a class="jxr_linenumber" name="L1554" href="#L1554">1554</a> <em class="jxr_javadoccomment">/** Set the heading preceding the options list. May contain embedded {@linkplain java.util.Formatter format specifiers}.</em>
<a class="jxr_linenumber" name="L1555" href="#L1555">1555</a> <em class="jxr_javadoccomment"> * @return the heading preceding the options list</em>
<a class="jxr_linenumber" name="L1556" href="#L1556">1556</a> <em class="jxr_javadoccomment"> * @see Help#optionListHeading(Object...) */</em>
<a class="jxr_linenumber" name="L1557" href="#L1557">1557</a> String optionListHeading() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1558" href="#L1558">1558</a>
<a class="jxr_linenumber" name="L1559" href="#L1559">1559</a> <em class="jxr_javadoccomment">/** Specify {@code false} to show Options in declaration order. The default is to sort alphabetically.</em>
<a class="jxr_linenumber" name="L1560" href="#L1560">1560</a> <em class="jxr_javadoccomment"> * @return whether options should be shown in alphabetic order.</em>
<a class="jxr_linenumber" name="L1561" href="#L1561">1561</a> <em class="jxr_javadoccomment"> * @see Help#sortOptions */</em>
<a class="jxr_linenumber" name="L1562" href="#L1562">1562</a> <strong class="jxr_keyword">boolean</strong> sortOptions() <strong class="jxr_keyword">default</strong> <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L1563" href="#L1563">1563</a>
<a class="jxr_linenumber" name="L1564" href="#L1564">1564</a> <em class="jxr_javadoccomment">/** Prefix required options with this character in the options list. The default is no marker: the synopsis</em>
<a class="jxr_linenumber" name="L1565" href="#L1565">1565</a> <em class="jxr_javadoccomment"> * indicates which options and parameters are required.</em>
<a class="jxr_linenumber" name="L1566" href="#L1566">1566</a> <em class="jxr_javadoccomment"> * @return the character to show in the options list to mark required options</em>
<a class="jxr_linenumber" name="L1567" href="#L1567">1567</a> <em class="jxr_javadoccomment"> * @see Help#requiredOptionMarker */</em>
<a class="jxr_linenumber" name="L1568" href="#L1568">1568</a> <strong class="jxr_keyword">char</strong> requiredOptionMarker() <strong class="jxr_keyword">default</strong> ' ';
<a class="jxr_linenumber" name="L1569" href="#L1569">1569</a>
<a class="jxr_linenumber" name="L1570" href="#L1570">1570</a> <em class="jxr_javadoccomment">/** Specify {@code true} to show default values in the description column of the options list (except for</em>
<a class="jxr_linenumber" name="L1571" href="#L1571">1571</a> <em class="jxr_javadoccomment"> * boolean options). False by default.</em>
<a class="jxr_linenumber" name="L1572" href="#L1572">1572</a> <em class="jxr_javadoccomment"> * @return whether the default values for options and parameters should be shown in the description column</em>
<a class="jxr_linenumber" name="L1573" href="#L1573">1573</a> <em class="jxr_javadoccomment"> * @see Help#showDefaultValues */</em>
<a class="jxr_linenumber" name="L1574" href="#L1574">1574</a> <strong class="jxr_keyword">boolean</strong> showDefaultValues() <strong class="jxr_keyword">default</strong> false;
<a class="jxr_linenumber" name="L1575" href="#L1575">1575</a>
<a class="jxr_linenumber" name="L1576" href="#L1576">1576</a> <em class="jxr_javadoccomment">/** Set the heading preceding the subcommands list. May contain embedded {@linkplain java.util.Formatter format specifiers}.</em>
<a class="jxr_linenumber" name="L1577" href="#L1577">1577</a> <em class="jxr_javadoccomment"> * The default heading is {@code "Commands:%n"} (with a line break at the end).</em>
<a class="jxr_linenumber" name="L1578" href="#L1578">1578</a> <em class="jxr_javadoccomment"> * @return the heading preceding the subcommands list</em>
<a class="jxr_linenumber" name="L1579" href="#L1579">1579</a> <em class="jxr_javadoccomment"> * @see Help#commandListHeading(Object...) */</em>
<a class="jxr_linenumber" name="L1580" href="#L1580">1580</a> String commandListHeading() <strong class="jxr_keyword">default</strong> <span class="jxr_string">"Commands:%n"</span>;
<a class="jxr_linenumber" name="L1581" href="#L1581">1581</a>
<a class="jxr_linenumber" name="L1582" href="#L1582">1582</a> <em class="jxr_javadoccomment">/** Set the heading preceding the footer section. May contain embedded {@linkplain java.util.Formatter format specifiers}.</em>
<a class="jxr_linenumber" name="L1583" href="#L1583">1583</a> <em class="jxr_javadoccomment"> * @return the heading preceding the footer section</em>
<a class="jxr_linenumber" name="L1584" href="#L1584">1584</a> <em class="jxr_javadoccomment"> * @see Help#footerHeading(Object...) */</em>
<a class="jxr_linenumber" name="L1585" href="#L1585">1585</a> String footerHeading() <strong class="jxr_keyword">default</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L1586" href="#L1586">1586</a>
<a class="jxr_linenumber" name="L1587" href="#L1587">1587</a> <em class="jxr_javadoccomment">/** Optional text to display after the list of options.</em>
<a class="jxr_linenumber" name="L1588" href="#L1588">1588</a> <em class="jxr_javadoccomment"> * @return text to display after the list of options</em>
<a class="jxr_linenumber" name="L1589" href="#L1589">1589</a> <em class="jxr_javadoccomment"> * @see Help#footer</em>
<a class="jxr_linenumber" name="L1590" href="#L1590">1590</a> <em class="jxr_javadoccomment"> * @see Help#footer(Object...) */</em>
<a class="jxr_linenumber" name="L1591" href="#L1591">1591</a> String[] footer() <strong class="jxr_keyword">default</strong> {};
<a class="jxr_linenumber" name="L1592" href="#L1592">1592</a> }
<a class="jxr_linenumber" name="L1593" href="#L1593">1593</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1594" href="#L1594">1594</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1595" href="#L1595">1595</a> <em class="jxr_javadoccomment"> * When parsing command line arguments and initializing</em>
<a class="jxr_linenumber" name="L1596" href="#L1596">1596</a> <em class="jxr_javadoccomment"> * fields annotated with {@link Option @Option} or {@link Parameters @Parameters},</em>
<a class="jxr_linenumber" name="L1597" href="#L1597">1597</a> <em class="jxr_javadoccomment"> * String values can be converted to any type for which a {@code ITypeConverter} is registered.</em>
<a class="jxr_linenumber" name="L1598" href="#L1598">1598</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1599" href="#L1599">1599</a> <em class="jxr_javadoccomment"> * This interface defines the contract for classes that know how to convert a String into some domain object.</em>
<a class="jxr_linenumber" name="L1600" href="#L1600">1600</a> <em class="jxr_javadoccomment"> * Custom converters can be registered with the {@link #registerConverter(Class, ITypeConverter)} method.</em>
<a class="jxr_linenumber" name="L1601" href="#L1601">1601</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;&lt;p&gt;</em>
<a class="jxr_linenumber" name="L1602" href="#L1602">1602</a> <em class="jxr_javadoccomment"> * Java 8 lambdas make it easy to register custom type converters:</em>
<a class="jxr_linenumber" name="L1603" href="#L1603">1603</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1604" href="#L1604">1604</a> <em class="jxr_javadoccomment"> * &lt;pre&gt;</em>
<a class="jxr_linenumber" name="L1605" href="#L1605">1605</a> <em class="jxr_javadoccomment"> * commandLine.registerConverter(java.nio.file.Path.class, s -&amp;gt; java.nio.file.Paths.get(s));</em>
<a class="jxr_linenumber" name="L1606" href="#L1606">1606</a> <em class="jxr_javadoccomment"> * commandLine.registerConverter(java.time.Duration.class, s -&amp;gt; java.time.Duration.parse(s));&lt;/pre&gt;</em>
<a class="jxr_linenumber" name="L1607" href="#L1607">1607</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L1608" href="#L1608">1608</a> <em class="jxr_javadoccomment"> * Built-in type converters are pre-registered for the following java 1.5 types:</em>
<a class="jxr_linenumber" name="L1609" href="#L1609">1609</a> <em class="jxr_javadoccomment"> * &lt;/p&gt;</em>
<a class="jxr_linenumber" name="L1610" href="#L1610">1610</a> <em class="jxr_javadoccomment"> * &lt;ul&gt;</em>
<a class="jxr_linenumber" name="L1611" href="#L1611">1611</a> <em class="jxr_javadoccomment"> * &lt;li&gt;all primitive types&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1612" href="#L1612">1612</a> <em class="jxr_javadoccomment"> * &lt;li&gt;all primitive wrapper types: Boolean, Byte, Character, Double, Float, Integer, Long, Short&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1613" href="#L1613">1613</a> <em class="jxr_javadoccomment"> * &lt;li&gt;any enum&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1614" href="#L1614">1614</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.io.File&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1615" href="#L1615">1615</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.math.BigDecimal&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1616" href="#L1616">1616</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.math.BigInteger&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1617" href="#L1617">1617</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.net.InetAddress&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1618" href="#L1618">1618</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.net.URI&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1619" href="#L1619">1619</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.net.URL&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1620" href="#L1620">1620</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.nio.charset.Charset&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1621" href="#L1621">1621</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.sql.Time&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1622" href="#L1622">1622</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.util.Date&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1623" href="#L1623">1623</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.util.UUID&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1624" href="#L1624">1624</a> <em class="jxr_javadoccomment"> * &lt;li&gt;java.util.regex.Pattern&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1625" href="#L1625">1625</a> <em class="jxr_javadoccomment"> * &lt;li&gt;StringBuilder&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1626" href="#L1626">1626</a> <em class="jxr_javadoccomment"> * &lt;li&gt;CharSequence&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1627" href="#L1627">1627</a> <em class="jxr_javadoccomment"> * &lt;li&gt;String&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L1628" href="#L1628">1628</a> <em class="jxr_javadoccomment"> * &lt;/ul&gt;</em>
<a class="jxr_linenumber" name="L1629" href="#L1629">1629</a> <em class="jxr_javadoccomment"> * @param &lt;K&gt; the type of the object that is the result of the conversion</em>
<a class="jxr_linenumber" name="L1630" href="#L1630">1630</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1631" href="#L1631">1631</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">interface</strong> ITypeConverter&lt;K&gt; {
<a class="jxr_linenumber" name="L1632" href="#L1632">1632</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1633" href="#L1633">1633</a> <em class="jxr_javadoccomment"> * Converts the specified command line argument value to some domain object.</em>
<a class="jxr_linenumber" name="L1634" href="#L1634">1634</a> <em class="jxr_javadoccomment"> * @param value the command line argument String value</em>
<a class="jxr_linenumber" name="L1635" href="#L1635">1635</a> <em class="jxr_javadoccomment"> * @return the resulting domain object</em>
<a class="jxr_linenumber" name="L1636" href="#L1636">1636</a> <em class="jxr_javadoccomment"> * @throws Exception an exception detailing what went wrong during the conversion</em>
<a class="jxr_linenumber" name="L1637" href="#L1637">1637</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1638" href="#L1638">1638</a> K convert(String value) <strong class="jxr_keyword">throws</strong> Exception;
<a class="jxr_linenumber" name="L1639" href="#L1639">1639</a> }
<a class="jxr_linenumber" name="L1640" href="#L1640">1640</a> <em class="jxr_javadoccomment">/** Describes the number of parameters required and accepted by an option or a positional parameter.</em>
<a class="jxr_linenumber" name="L1641" href="#L1641">1641</a> <em class="jxr_javadoccomment"> * @since 0.9.7</em>
<a class="jxr_linenumber" name="L1642" href="#L1642">1642</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1643" href="#L1643">1643</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> <strong class="jxr_keyword">implements</strong> Comparable&lt;Range&gt; {
<a class="jxr_linenumber" name="L1644" href="#L1644">1644</a> <em class="jxr_javadoccomment">/** Required number of parameters for an option or positional parameter. */</em>
<a class="jxr_linenumber" name="L1645" href="#L1645">1645</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> min;
<a class="jxr_linenumber" name="L1646" href="#L1646">1646</a> <em class="jxr_javadoccomment">/** Maximum accepted number of parameters for an option or positional parameter. */</em>
<a class="jxr_linenumber" name="L1647" href="#L1647">1647</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> max;
<a class="jxr_linenumber" name="L1648" href="#L1648">1648</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> isVariable;
<a class="jxr_linenumber" name="L1649" href="#L1649">1649</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> isUnspecified;
<a class="jxr_linenumber" name="L1650" href="#L1650">1650</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> String originalValue;
<a class="jxr_linenumber" name="L1651" href="#L1651">1651</a>
<a class="jxr_linenumber" name="L1652" href="#L1652">1652</a> <em class="jxr_javadoccomment">/** Constructs a new Range object with the specified parameters.</em>
<a class="jxr_linenumber" name="L1653" href="#L1653">1653</a> <em class="jxr_javadoccomment"> * @param min minimum number of required parameters</em>
<a class="jxr_linenumber" name="L1654" href="#L1654">1654</a> <em class="jxr_javadoccomment"> * @param max maximum number of allowed parameters (or Integer.MAX_VALUE if variable)</em>
<a class="jxr_linenumber" name="L1655" href="#L1655">1655</a> <em class="jxr_javadoccomment"> * @param variable {@code true} if any number or parameters is allowed, {@code false} otherwise</em>
<a class="jxr_linenumber" name="L1656" href="#L1656">1656</a> <em class="jxr_javadoccomment"> * @param unspecified {@code true} if no arity was specified on the option/parameter (value is based on type)</em>
<a class="jxr_linenumber" name="L1657" href="#L1657">1657</a> <em class="jxr_javadoccomment"> * @param originalValue the original value that was specified on the option or parameter</em>
<a class="jxr_linenumber" name="L1658" href="#L1658">1658</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1659" href="#L1659">1659</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a>(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> min, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> max, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> variable, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> unspecified, <strong class="jxr_keyword">final</strong> String originalValue) {
<a class="jxr_linenumber" name="L1660" href="#L1660">1660</a> <strong class="jxr_keyword">this</strong>.min = min;
<a class="jxr_linenumber" name="L1661" href="#L1661">1661</a> <strong class="jxr_keyword">this</strong>.max = max;
<a class="jxr_linenumber" name="L1662" href="#L1662">1662</a> <strong class="jxr_keyword">this</strong>.isVariable = variable;
<a class="jxr_linenumber" name="L1663" href="#L1663">1663</a> <strong class="jxr_keyword">this</strong>.isUnspecified = unspecified;
<a class="jxr_linenumber" name="L1664" href="#L1664">1664</a> <strong class="jxr_keyword">this</strong>.originalValue = originalValue;
<a class="jxr_linenumber" name="L1665" href="#L1665">1665</a> }
<a class="jxr_linenumber" name="L1666" href="#L1666">1666</a> <em class="jxr_javadoccomment">/** Returns a new {@code Range} based on the {@link Option#arity()} annotation on the specified field,</em>
<a class="jxr_linenumber" name="L1667" href="#L1667">1667</a> <em class="jxr_javadoccomment"> * or the field type's default arity if no arity was specified.</em>
<a class="jxr_linenumber" name="L1668" href="#L1668">1668</a> <em class="jxr_javadoccomment"> * @param field the field whose Option annotation to inspect</em>
<a class="jxr_linenumber" name="L1669" href="#L1669">1669</a> <em class="jxr_javadoccomment"> * @return a new {@code Range} based on the Option arity annotation on the specified field */</em>
<a class="jxr_linenumber" name="L1670" href="#L1670">1670</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> optionArity(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L1671" href="#L1671">1671</a> <strong class="jxr_keyword">return</strong> field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)
<a class="jxr_linenumber" name="L1672" href="#L1672">1672</a> ? adjustForType(Range.valueOf(field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).arity()), field)
<a class="jxr_linenumber" name="L1673" href="#L1673">1673</a> : <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a>(0, 0, false, <strong class="jxr_keyword">true</strong>, <span class="jxr_string">"0"</span>);
<a class="jxr_linenumber" name="L1674" href="#L1674">1674</a> }
<a class="jxr_linenumber" name="L1675" href="#L1675">1675</a> <em class="jxr_javadoccomment">/** Returns a new {@code Range} based on the {@link Parameters#arity()} annotation on the specified field,</em>
<a class="jxr_linenumber" name="L1676" href="#L1676">1676</a> <em class="jxr_javadoccomment"> * or the field type's default arity if no arity was specified.</em>
<a class="jxr_linenumber" name="L1677" href="#L1677">1677</a> <em class="jxr_javadoccomment"> * @param field the field whose Parameters annotation to inspect</em>
<a class="jxr_linenumber" name="L1678" href="#L1678">1678</a> <em class="jxr_javadoccomment"> * @return a new {@code Range} based on the Parameters arity annotation on the specified field */</em>
<a class="jxr_linenumber" name="L1679" href="#L1679">1679</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> parameterArity(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L1680" href="#L1680">1680</a> <strong class="jxr_keyword">return</strong> field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>)
<a class="jxr_linenumber" name="L1681" href="#L1681">1681</a> ? adjustForType(Range.valueOf(field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).arity()), field)
<a class="jxr_linenumber" name="L1682" href="#L1682">1682</a> : <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a>(0, 0, false, <strong class="jxr_keyword">true</strong>, <span class="jxr_string">"0"</span>);
<a class="jxr_linenumber" name="L1683" href="#L1683">1683</a> }
<a class="jxr_linenumber" name="L1684" href="#L1684">1684</a> <em class="jxr_javadoccomment">/** Returns a new {@code Range} based on the {@link Parameters#index()} annotation on the specified field.</em>
<a class="jxr_linenumber" name="L1685" href="#L1685">1685</a> <em class="jxr_javadoccomment"> * @param field the field whose Parameters annotation to inspect</em>
<a class="jxr_linenumber" name="L1686" href="#L1686">1686</a> <em class="jxr_javadoccomment"> * @return a new {@code Range} based on the Parameters index annotation on the specified field */</em>
<a class="jxr_linenumber" name="L1687" href="#L1687">1687</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> parameterIndex(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L1688" href="#L1688">1688</a> <strong class="jxr_keyword">return</strong> field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>)
<a class="jxr_linenumber" name="L1689" href="#L1689">1689</a> ? Range.valueOf(field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).index())
<a class="jxr_linenumber" name="L1690" href="#L1690">1690</a> : <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a>(0, 0, false, <strong class="jxr_keyword">true</strong>, <span class="jxr_string">"0"</span>);
<a class="jxr_linenumber" name="L1691" href="#L1691">1691</a> }
<a class="jxr_linenumber" name="L1692" href="#L1692">1692</a> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> adjustForType(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> result, <strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L1693" href="#L1693">1693</a> <strong class="jxr_keyword">return</strong> result.isUnspecified ? defaultArity(field) : result;
<a class="jxr_linenumber" name="L1694" href="#L1694">1694</a> }
<a class="jxr_linenumber" name="L1695" href="#L1695">1695</a> <em class="jxr_javadoccomment">/** Returns the default arity {@code Range}: for {@link Option options} this is 0 for booleans and 1 for</em>
<a class="jxr_linenumber" name="L1696" href="#L1696">1696</a> <em class="jxr_javadoccomment"> * other types, for {@link Parameters parameters} booleans have arity 0, arrays or Collections have</em>
<a class="jxr_linenumber" name="L1697" href="#L1697">1697</a> <em class="jxr_javadoccomment"> * arity "0..*", and other types have arity 1.</em>
<a class="jxr_linenumber" name="L1698" href="#L1698">1698</a> <em class="jxr_javadoccomment"> * @param field the field whose default arity to return</em>
<a class="jxr_linenumber" name="L1699" href="#L1699">1699</a> <em class="jxr_javadoccomment"> * @return a new {@code Range} indicating the default arity of the specified field</em>
<a class="jxr_linenumber" name="L1700" href="#L1700">1700</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L1701" href="#L1701">1701</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> defaultArity(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L1702" href="#L1702">1702</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; type = field.getType();
<a class="jxr_linenumber" name="L1703" href="#L1703">1703</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L1704" href="#L1704">1704</a> <strong class="jxr_keyword">return</strong> defaultArity(type);
<a class="jxr_linenumber" name="L1705" href="#L1705">1705</a> }
<a class="jxr_linenumber" name="L1706" href="#L1706">1706</a> <strong class="jxr_keyword">if</strong> (isMultiValue(type)) {
<a class="jxr_linenumber" name="L1707" href="#L1707">1707</a> <strong class="jxr_keyword">return</strong> Range.valueOf(<span class="jxr_string">"0..1"</span>);
<a class="jxr_linenumber" name="L1708" href="#L1708">1708</a> }
<a class="jxr_linenumber" name="L1709" href="#L1709">1709</a> <strong class="jxr_keyword">return</strong> Range.valueOf(<span class="jxr_string">"1"</span>);<em class="jxr_comment">// for single-valued fields (incl. boolean positional parameters)</em>
<a class="jxr_linenumber" name="L1710" href="#L1710">1710</a> }
<a class="jxr_linenumber" name="L1711" href="#L1711">1711</a> <em class="jxr_javadoccomment">/** Returns the default arity {@code Range} for {@link Option options}: booleans have arity 0, other types have arity 1.</em>
<a class="jxr_linenumber" name="L1712" href="#L1712">1712</a> <em class="jxr_javadoccomment"> * @param type the type whose default arity to return</em>
<a class="jxr_linenumber" name="L1713" href="#L1713">1713</a> <em class="jxr_javadoccomment"> * @return a new {@code Range} indicating the default arity of the specified type */</em>
<a class="jxr_linenumber" name="L1714" href="#L1714">1714</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> defaultArity(<strong class="jxr_keyword">final</strong> Class&lt;?&gt; type) {
<a class="jxr_linenumber" name="L1715" href="#L1715">1715</a> <strong class="jxr_keyword">return</strong> isBoolean(type) ? Range.valueOf(<span class="jxr_string">"0"</span>) : Range.valueOf(<span class="jxr_string">"1"</span>);
<a class="jxr_linenumber" name="L1716" href="#L1716">1716</a> }
<a class="jxr_linenumber" name="L1717" href="#L1717">1717</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> size() { <strong class="jxr_keyword">return</strong> 1 + max - min; }
<a class="jxr_linenumber" name="L1718" href="#L1718">1718</a> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> parameterCapacity(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L1719" href="#L1719">1719</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity = parameterArity(field);
<a class="jxr_linenumber" name="L1720" href="#L1720">1720</a> <strong class="jxr_keyword">if</strong> (!isMultiValue(field)) { <strong class="jxr_keyword">return</strong> arity; }
<a class="jxr_linenumber" name="L1721" href="#L1721">1721</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> index = parameterIndex(field);
<a class="jxr_linenumber" name="L1722" href="#L1722">1722</a> <strong class="jxr_keyword">if</strong> (arity.max == 0) { <strong class="jxr_keyword">return</strong> arity; }
<a class="jxr_linenumber" name="L1723" href="#L1723">1723</a> <strong class="jxr_keyword">if</strong> (index.size() == 1) { <strong class="jxr_keyword">return</strong> arity; }
<a class="jxr_linenumber" name="L1724" href="#L1724">1724</a> <strong class="jxr_keyword">if</strong> (index.isVariable) { <strong class="jxr_keyword">return</strong> Range.valueOf(arity.min + <span class="jxr_string">"..*"</span>); }
<a class="jxr_linenumber" name="L1725" href="#L1725">1725</a> <strong class="jxr_keyword">if</strong> (arity.size() == 1) { <strong class="jxr_keyword">return</strong> Range.valueOf(arity.min * index.size() + <span class="jxr_string">""</span>); }
<a class="jxr_linenumber" name="L1726" href="#L1726">1726</a> <strong class="jxr_keyword">if</strong> (arity.isVariable) { <strong class="jxr_keyword">return</strong> Range.valueOf(arity.min * index.size() + <span class="jxr_string">"..*"</span>); }
<a class="jxr_linenumber" name="L1727" href="#L1727">1727</a> <strong class="jxr_keyword">return</strong> Range.valueOf(arity.min * index.size() + <span class="jxr_string">".."</span> + arity.max * index.size());
<a class="jxr_linenumber" name="L1728" href="#L1728">1728</a> }
<a class="jxr_linenumber" name="L1729" href="#L1729">1729</a> <em class="jxr_javadoccomment">/** Leniently parses the specified String as an {@code Range} value and return the result. A range string can</em>
<a class="jxr_linenumber" name="L1730" href="#L1730">1730</a> <em class="jxr_javadoccomment"> * be a fixed integer value or a range of the form {@code MIN_VALUE + ".." + MAX_VALUE}. If the</em>
<a class="jxr_linenumber" name="L1731" href="#L1731">1731</a> <em class="jxr_javadoccomment"> * {@code MIN_VALUE} string is not numeric, the minimum is zero. If the {@code MAX_VALUE} is not numeric, the</em>
<a class="jxr_linenumber" name="L1732" href="#L1732">1732</a> <em class="jxr_javadoccomment"> * range is taken to be variable and the maximum is {@code Integer.MAX_VALUE}.</em>
<a class="jxr_linenumber" name="L1733" href="#L1733">1733</a> <em class="jxr_javadoccomment"> * @param range the value range string to parse</em>
<a class="jxr_linenumber" name="L1734" href="#L1734">1734</a> <em class="jxr_javadoccomment"> * @return a new {@code Range} value */</em>
<a class="jxr_linenumber" name="L1735" href="#L1735">1735</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> valueOf(String range) {
<a class="jxr_linenumber" name="L1736" href="#L1736">1736</a> range = range.trim();
<a class="jxr_linenumber" name="L1737" href="#L1737">1737</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> unspecified = range.length() == 0 || range.startsWith(<span class="jxr_string">".."</span>); <em class="jxr_comment">// || range.endsWith("..");</em>
<a class="jxr_linenumber" name="L1738" href="#L1738">1738</a> <strong class="jxr_keyword">int</strong> min = -1, max = -1;
<a class="jxr_linenumber" name="L1739" href="#L1739">1739</a> <strong class="jxr_keyword">boolean</strong> variable = false;
<a class="jxr_linenumber" name="L1740" href="#L1740">1740</a> <strong class="jxr_keyword">int</strong> dots = -1;
<a class="jxr_linenumber" name="L1741" href="#L1741">1741</a> <strong class="jxr_keyword">if</strong> ((dots = range.indexOf(<span class="jxr_string">".."</span>)) &gt;= 0) {
<a class="jxr_linenumber" name="L1742" href="#L1742">1742</a> min = parseInt(range.substring(0, dots), 0);
<a class="jxr_linenumber" name="L1743" href="#L1743">1743</a> max = parseInt(range.substring(dots + 2), Integer.MAX_VALUE);
<a class="jxr_linenumber" name="L1744" href="#L1744">1744</a> variable = max == Integer.MAX_VALUE;
<a class="jxr_linenumber" name="L1745" href="#L1745">1745</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L1746" href="#L1746">1746</a> max = parseInt(range, Integer.MAX_VALUE);
<a class="jxr_linenumber" name="L1747" href="#L1747">1747</a> variable = max == Integer.MAX_VALUE;
<a class="jxr_linenumber" name="L1748" href="#L1748">1748</a> min = variable ? 0 : max;
<a class="jxr_linenumber" name="L1749" href="#L1749">1749</a> }
<a class="jxr_linenumber" name="L1750" href="#L1750">1750</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> result = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a>(min, max, variable, unspecified, range);
<a class="jxr_linenumber" name="L1751" href="#L1751">1751</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L1752" href="#L1752">1752</a> }
<a class="jxr_linenumber" name="L1753" href="#L1753">1753</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> parseInt(<strong class="jxr_keyword">final</strong> String str, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> defaultValue) {
<a class="jxr_linenumber" name="L1754" href="#L1754">1754</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L1755" href="#L1755">1755</a> <strong class="jxr_keyword">return</strong> Integer.parseInt(str);
<a class="jxr_linenumber" name="L1756" href="#L1756">1756</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ex) {
<a class="jxr_linenumber" name="L1757" href="#L1757">1757</a> <strong class="jxr_keyword">return</strong> defaultValue;
<a class="jxr_linenumber" name="L1758" href="#L1758">1758</a> }
<a class="jxr_linenumber" name="L1759" href="#L1759">1759</a> }
<a class="jxr_linenumber" name="L1760" href="#L1760">1760</a> <em class="jxr_javadoccomment">/** Returns a new Range object with the {@code min} value replaced by the specified value.</em>
<a class="jxr_linenumber" name="L1761" href="#L1761">1761</a> <em class="jxr_javadoccomment"> * The {@code max} of the returned Range is guaranteed not to be less than the new {@code min} value.</em>
<a class="jxr_linenumber" name="L1762" href="#L1762">1762</a> <em class="jxr_javadoccomment"> * @param newMin the {@code min} value of the returned Range object</em>
<a class="jxr_linenumber" name="L1763" href="#L1763">1763</a> <em class="jxr_javadoccomment"> * @return a new Range object with the specified {@code min} value */</em>
<a class="jxr_linenumber" name="L1764" href="#L1764">1764</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> min(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> newMin) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Range(newMin, Math.max(newMin, max), isVariable, isUnspecified, originalValue); }
<a class="jxr_linenumber" name="L1765" href="#L1765">1765</a>
<a class="jxr_linenumber" name="L1766" href="#L1766">1766</a> <em class="jxr_javadoccomment">/** Returns a new Range object with the {@code max} value replaced by the specified value.</em>
<a class="jxr_linenumber" name="L1767" href="#L1767">1767</a> <em class="jxr_javadoccomment"> * The {@code min} of the returned Range is guaranteed not to be greater than the new {@code max} value.</em>
<a class="jxr_linenumber" name="L1768" href="#L1768">1768</a> <em class="jxr_javadoccomment"> * @param newMax the {@code max} value of the returned Range object</em>
<a class="jxr_linenumber" name="L1769" href="#L1769">1769</a> <em class="jxr_javadoccomment"> * @return a new Range object with the specified {@code max} value */</em>
<a class="jxr_linenumber" name="L1770" href="#L1770">1770</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> max(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> newMax) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Range(Math.min(min, newMax), newMax, isVariable, isUnspecified, originalValue); }
<a class="jxr_linenumber" name="L1771" href="#L1771">1771</a>
<a class="jxr_linenumber" name="L1772" href="#L1772">1772</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1773" href="#L1773">1773</a> <em class="jxr_javadoccomment"> * Returns {@code true} if this Range includes the specified value, {@code false} otherwise.</em>
<a class="jxr_linenumber" name="L1774" href="#L1774">1774</a> <em class="jxr_javadoccomment"> * @param value the value to check</em>
<a class="jxr_linenumber" name="L1775" href="#L1775">1775</a> <em class="jxr_javadoccomment"> * @return {@code true} if the specified value is not less than the minimum and not greater than the maximum of this Range</em>
<a class="jxr_linenumber" name="L1776" href="#L1776">1776</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1777" href="#L1777">1777</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> contains(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> value) { <strong class="jxr_keyword">return</strong> min &lt;= value &amp;&amp; max &gt;= value; }
<a class="jxr_linenumber" name="L1778" href="#L1778">1778</a>
<a class="jxr_linenumber" name="L1779" href="#L1779">1779</a> @Override
<a class="jxr_linenumber" name="L1780" href="#L1780">1780</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> equals(<strong class="jxr_keyword">final</strong> Object object) {
<a class="jxr_linenumber" name="L1781" href="#L1781">1781</a> <strong class="jxr_keyword">if</strong> (!(object instanceof Range)) { <strong class="jxr_keyword">return</strong> false; }
<a class="jxr_linenumber" name="L1782" href="#L1782">1782</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> other = (Range) object;
<a class="jxr_linenumber" name="L1783" href="#L1783">1783</a> <strong class="jxr_keyword">return</strong> other.max == <strong class="jxr_keyword">this</strong>.max &amp;&amp; other.min == <strong class="jxr_keyword">this</strong>.min &amp;&amp; other.isVariable == <strong class="jxr_keyword">this</strong>.isVariable;
<a class="jxr_linenumber" name="L1784" href="#L1784">1784</a> }
<a class="jxr_linenumber" name="L1785" href="#L1785">1785</a> @Override
<a class="jxr_linenumber" name="L1786" href="#L1786">1786</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> hashCode() {
<a class="jxr_linenumber" name="L1787" href="#L1787">1787</a> <strong class="jxr_keyword">return</strong> ((17 * 37 + max) * 37 + min) * 37 + (isVariable ? 1 : 0);
<a class="jxr_linenumber" name="L1788" href="#L1788">1788</a> }
<a class="jxr_linenumber" name="L1789" href="#L1789">1789</a> @Override
<a class="jxr_linenumber" name="L1790" href="#L1790">1790</a> <strong class="jxr_keyword">public</strong> String toString() {
<a class="jxr_linenumber" name="L1791" href="#L1791">1791</a> <strong class="jxr_keyword">return</strong> min == max ? String.valueOf(min) : min + <span class="jxr_string">".."</span> + (isVariable ? <span class="jxr_string">"*"</span> : max);
<a class="jxr_linenumber" name="L1792" href="#L1792">1792</a> }
<a class="jxr_linenumber" name="L1793" href="#L1793">1793</a> @Override
<a class="jxr_linenumber" name="L1794" href="#L1794">1794</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> compareTo(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> other) {
<a class="jxr_linenumber" name="L1795" href="#L1795">1795</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> result = min - other.min;
<a class="jxr_linenumber" name="L1796" href="#L1796">1796</a> <strong class="jxr_keyword">return</strong> (result == 0) ? max - other.max : result;
<a class="jxr_linenumber" name="L1797" href="#L1797">1797</a> }
<a class="jxr_linenumber" name="L1798" href="#L1798">1798</a> }
<a class="jxr_linenumber" name="L1799" href="#L1799">1799</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> init(<strong class="jxr_keyword">final</strong> Class&lt;?&gt; cls,
<a class="jxr_linenumber" name="L1800" href="#L1800">1800</a> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; requiredFields,
<a class="jxr_linenumber" name="L1801" href="#L1801">1801</a> <strong class="jxr_keyword">final</strong> Map&lt;String, Field&gt; optionName2Field,
<a class="jxr_linenumber" name="L1802" href="#L1802">1802</a> <strong class="jxr_keyword">final</strong> Map&lt;Character, Field&gt; singleCharOption2Field,
<a class="jxr_linenumber" name="L1803" href="#L1803">1803</a> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; positionalParametersFields) {
<a class="jxr_linenumber" name="L1804" href="#L1804">1804</a> <strong class="jxr_keyword">final</strong> Field[] declaredFields = cls.getDeclaredFields();
<a class="jxr_linenumber" name="L1805" href="#L1805">1805</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field field : declaredFields) {
<a class="jxr_linenumber" name="L1806" href="#L1806">1806</a> field.setAccessible(<strong class="jxr_keyword">true</strong>);
<a class="jxr_linenumber" name="L1807" href="#L1807">1807</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L1808" href="#L1808">1808</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option = field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L1809" href="#L1809">1809</a> <strong class="jxr_keyword">if</strong> (option.required()) {
<a class="jxr_linenumber" name="L1810" href="#L1810">1810</a> requiredFields.add(field);
<a class="jxr_linenumber" name="L1811" href="#L1811">1811</a> }
<a class="jxr_linenumber" name="L1812" href="#L1812">1812</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> String name : option.names()) { <em class="jxr_comment">// cannot be null or empty</em>
<a class="jxr_linenumber" name="L1813" href="#L1813">1813</a> <strong class="jxr_keyword">final</strong> Field existing = optionName2Field.put(name, field);
<a class="jxr_linenumber" name="L1814" href="#L1814">1814</a> <strong class="jxr_keyword">if</strong> (existing != <strong class="jxr_keyword">null</strong> &amp;&amp; existing != field) {
<a class="jxr_linenumber" name="L1815" href="#L1815">1815</a> <strong class="jxr_keyword">throw</strong> DuplicateOptionAnnotationsException.create(name, field, existing);
<a class="jxr_linenumber" name="L1816" href="#L1816">1816</a> }
<a class="jxr_linenumber" name="L1817" href="#L1817">1817</a> <strong class="jxr_keyword">if</strong> (name.length() == 2 &amp;&amp; name.startsWith(<span class="jxr_string">"-"</span>)) {
<a class="jxr_linenumber" name="L1818" href="#L1818">1818</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">char</strong> flag = name.charAt(1);
<a class="jxr_linenumber" name="L1819" href="#L1819">1819</a> <strong class="jxr_keyword">final</strong> Field existing2 = singleCharOption2Field.put(flag, field);
<a class="jxr_linenumber" name="L1820" href="#L1820">1820</a> <strong class="jxr_keyword">if</strong> (existing2 != <strong class="jxr_keyword">null</strong> &amp;&amp; existing2 != field) {
<a class="jxr_linenumber" name="L1821" href="#L1821">1821</a> <strong class="jxr_keyword">throw</strong> DuplicateOptionAnnotationsException.create(name, field, existing2);
<a class="jxr_linenumber" name="L1822" href="#L1822">1822</a> }
<a class="jxr_linenumber" name="L1823" href="#L1823">1823</a> }
<a class="jxr_linenumber" name="L1824" href="#L1824">1824</a> }
<a class="jxr_linenumber" name="L1825" href="#L1825">1825</a> }
<a class="jxr_linenumber" name="L1826" href="#L1826">1826</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L1827" href="#L1827">1827</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L1828" href="#L1828">1828</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DuplicateOptionAnnotationsException</a>(<span class="jxr_string">"A field can be either @Option or @Parameters, but '"</span>
<a class="jxr_linenumber" name="L1829" href="#L1829">1829</a> + field.getName() + <span class="jxr_string">"' is both."</span>);
<a class="jxr_linenumber" name="L1830" href="#L1830">1830</a> }
<a class="jxr_linenumber" name="L1831" href="#L1831">1831</a> positionalParametersFields.add(field);
<a class="jxr_linenumber" name="L1832" href="#L1832">1832</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity = Range.parameterArity(field);
<a class="jxr_linenumber" name="L1833" href="#L1833">1833</a> <strong class="jxr_keyword">if</strong> (arity.min &gt; 0) {
<a class="jxr_linenumber" name="L1834" href="#L1834">1834</a> requiredFields.add(field);
<a class="jxr_linenumber" name="L1835" href="#L1835">1835</a> }
<a class="jxr_linenumber" name="L1836" href="#L1836">1836</a> }
<a class="jxr_linenumber" name="L1837" href="#L1837">1837</a> }
<a class="jxr_linenumber" name="L1838" href="#L1838">1838</a> }
<a class="jxr_linenumber" name="L1839" href="#L1839">1839</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> validatePositionalParameters(<strong class="jxr_keyword">final</strong> List&lt;Field&gt; positionalParametersFields) {
<a class="jxr_linenumber" name="L1840" href="#L1840">1840</a> <strong class="jxr_keyword">int</strong> min = 0;
<a class="jxr_linenumber" name="L1841" href="#L1841">1841</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field field : positionalParametersFields) {
<a class="jxr_linenumber" name="L1842" href="#L1842">1842</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> index = Range.parameterIndex(field);
<a class="jxr_linenumber" name="L1843" href="#L1843">1843</a> <strong class="jxr_keyword">if</strong> (index.min &gt; min) {
<a class="jxr_linenumber" name="L1844" href="#L1844">1844</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterIndexGapException</a>(<span class="jxr_string">"Missing field annotated with @Parameter(index="</span> + min +
<a class="jxr_linenumber" name="L1845" href="#L1845">1845</a> <span class="jxr_string">"). Nearest field '"</span> + field.getName() + <span class="jxr_string">"' has index="</span> + index.min);
<a class="jxr_linenumber" name="L1846" href="#L1846">1846</a> }
<a class="jxr_linenumber" name="L1847" href="#L1847">1847</a> min = Math.max(min, index.max);
<a class="jxr_linenumber" name="L1848" href="#L1848">1848</a> min = min == Integer.MAX_VALUE ? min : min + 1;
<a class="jxr_linenumber" name="L1849" href="#L1849">1849</a> }
<a class="jxr_linenumber" name="L1850" href="#L1850">1850</a> }
<a class="jxr_linenumber" name="L1851" href="#L1851">1851</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> &lt;T&gt; Stack&lt;T&gt; reverse(<strong class="jxr_keyword">final</strong> Stack&lt;T&gt; stack) {
<a class="jxr_linenumber" name="L1852" href="#L1852">1852</a> Collections.reverse(stack);
<a class="jxr_linenumber" name="L1853" href="#L1853">1853</a> <strong class="jxr_keyword">return</strong> stack;
<a class="jxr_linenumber" name="L1854" href="#L1854">1854</a> }
<a class="jxr_linenumber" name="L1855" href="#L1855">1855</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1856" href="#L1856">1856</a> <em class="jxr_javadoccomment"> * Helper class responsible for processing command line arguments.</em>
<a class="jxr_linenumber" name="L1857" href="#L1857">1857</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1858" href="#L1858">1858</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Interpreter</a> {
<a class="jxr_linenumber" name="L1859" href="#L1859">1859</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Map&lt;String, CommandLine&gt; commands = <strong class="jxr_keyword">new</strong> LinkedHashMap&lt;String, CommandLine&gt;();
<a class="jxr_linenumber" name="L1860" href="#L1860">1860</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Map&lt;Class&lt;?&gt;, ITypeConverter&lt;?&gt;&gt; converterRegistry = <strong class="jxr_keyword">new</strong> HashMap&lt;Class&lt;?&gt;, ITypeConverter&lt;?&gt;&gt;();
<a class="jxr_linenumber" name="L1861" href="#L1861">1861</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Map&lt;String, Field&gt; optionName2Field = <strong class="jxr_keyword">new</strong> HashMap&lt;String, Field&gt;();
<a class="jxr_linenumber" name="L1862" href="#L1862">1862</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Map&lt;Character, Field&gt; singleCharOption2Field = <strong class="jxr_keyword">new</strong> HashMap&lt;Character, Field&gt;();
<a class="jxr_linenumber" name="L1863" href="#L1863">1863</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; requiredFields = <strong class="jxr_keyword">new</strong> ArrayList&lt;Field&gt;();
<a class="jxr_linenumber" name="L1864" href="#L1864">1864</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; positionalParametersFields = <strong class="jxr_keyword">new</strong> ArrayList&lt;Field&gt;();
<a class="jxr_linenumber" name="L1865" href="#L1865">1865</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Object command;
<a class="jxr_linenumber" name="L1866" href="#L1866">1866</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> isHelpRequested;
<a class="jxr_linenumber" name="L1867" href="#L1867">1867</a> <strong class="jxr_keyword">private</strong> String separator = Help.DEFAULT_SEPARATOR;
<a class="jxr_linenumber" name="L1868" href="#L1868">1868</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> position;
<a class="jxr_linenumber" name="L1869" href="#L1869">1869</a>
<a class="jxr_linenumber" name="L1870" href="#L1870">1870</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Interpreter</a>(<strong class="jxr_keyword">final</strong> Object command) {
<a class="jxr_linenumber" name="L1871" href="#L1871">1871</a> converterRegistry.put(Path.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.PathConverter());
<a class="jxr_linenumber" name="L1872" href="#L1872">1872</a> converterRegistry.put(Object.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.StringConverter());
<a class="jxr_linenumber" name="L1873" href="#L1873">1873</a> converterRegistry.put(String.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.StringConverter());
<a class="jxr_linenumber" name="L1874" href="#L1874">1874</a> converterRegistry.put(StringBuilder.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.StringBuilderConverter());
<a class="jxr_linenumber" name="L1875" href="#L1875">1875</a> converterRegistry.put(CharSequence.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.CharSequenceConverter());
<a class="jxr_linenumber" name="L1876" href="#L1876">1876</a> converterRegistry.put(Byte.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.ByteConverter());
<a class="jxr_linenumber" name="L1877" href="#L1877">1877</a> converterRegistry.put(Byte.TYPE, <strong class="jxr_keyword">new</strong> BuiltIn.ByteConverter());
<a class="jxr_linenumber" name="L1878" href="#L1878">1878</a> converterRegistry.put(Boolean.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.BooleanConverter());
<a class="jxr_linenumber" name="L1879" href="#L1879">1879</a> converterRegistry.put(Boolean.TYPE, <strong class="jxr_keyword">new</strong> BuiltIn.BooleanConverter());
<a class="jxr_linenumber" name="L1880" href="#L1880">1880</a> converterRegistry.put(Character.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.CharacterConverter());
<a class="jxr_linenumber" name="L1881" href="#L1881">1881</a> converterRegistry.put(Character.TYPE, <strong class="jxr_keyword">new</strong> BuiltIn.CharacterConverter());
<a class="jxr_linenumber" name="L1882" href="#L1882">1882</a> converterRegistry.put(Short.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.ShortConverter());
<a class="jxr_linenumber" name="L1883" href="#L1883">1883</a> converterRegistry.put(Short.TYPE, <strong class="jxr_keyword">new</strong> BuiltIn.ShortConverter());
<a class="jxr_linenumber" name="L1884" href="#L1884">1884</a> converterRegistry.put(Integer.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.IntegerConverter());
<a class="jxr_linenumber" name="L1885" href="#L1885">1885</a> converterRegistry.put(Integer.TYPE, <strong class="jxr_keyword">new</strong> BuiltIn.IntegerConverter());
<a class="jxr_linenumber" name="L1886" href="#L1886">1886</a> converterRegistry.put(Long.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.LongConverter());
<a class="jxr_linenumber" name="L1887" href="#L1887">1887</a> converterRegistry.put(Long.TYPE, <strong class="jxr_keyword">new</strong> BuiltIn.LongConverter());
<a class="jxr_linenumber" name="L1888" href="#L1888">1888</a> converterRegistry.put(Float.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.FloatConverter());
<a class="jxr_linenumber" name="L1889" href="#L1889">1889</a> converterRegistry.put(Float.TYPE, <strong class="jxr_keyword">new</strong> BuiltIn.FloatConverter());
<a class="jxr_linenumber" name="L1890" href="#L1890">1890</a> converterRegistry.put(Double.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.DoubleConverter());
<a class="jxr_linenumber" name="L1891" href="#L1891">1891</a> converterRegistry.put(Double.TYPE, <strong class="jxr_keyword">new</strong> BuiltIn.DoubleConverter());
<a class="jxr_linenumber" name="L1892" href="#L1892">1892</a> converterRegistry.put(File.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.FileConverter());
<a class="jxr_linenumber" name="L1893" href="#L1893">1893</a> converterRegistry.put(URI.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.URIConverter());
<a class="jxr_linenumber" name="L1894" href="#L1894">1894</a> converterRegistry.put(URL.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.URLConverter());
<a class="jxr_linenumber" name="L1895" href="#L1895">1895</a> converterRegistry.put(Date.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.ISO8601DateConverter());
<a class="jxr_linenumber" name="L1896" href="#L1896">1896</a> converterRegistry.put(Time.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.ISO8601TimeConverter());
<a class="jxr_linenumber" name="L1897" href="#L1897">1897</a> converterRegistry.put(BigDecimal.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.BigDecimalConverter());
<a class="jxr_linenumber" name="L1898" href="#L1898">1898</a> converterRegistry.put(BigInteger.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.BigIntegerConverter());
<a class="jxr_linenumber" name="L1899" href="#L1899">1899</a> converterRegistry.put(Charset.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.CharsetConverter());
<a class="jxr_linenumber" name="L1900" href="#L1900">1900</a> converterRegistry.put(InetAddress.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.InetAddressConverter());
<a class="jxr_linenumber" name="L1901" href="#L1901">1901</a> converterRegistry.put(Pattern.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.PatternConverter());
<a class="jxr_linenumber" name="L1902" href="#L1902">1902</a> converterRegistry.put(UUID.<strong class="jxr_keyword">class</strong>, <strong class="jxr_keyword">new</strong> BuiltIn.UUIDConverter());
<a class="jxr_linenumber" name="L1903" href="#L1903">1903</a>
<a class="jxr_linenumber" name="L1904" href="#L1904">1904</a> <strong class="jxr_keyword">this</strong>.command = Assert.notNull(command, <span class="jxr_string">"command"</span>);
<a class="jxr_linenumber" name="L1905" href="#L1905">1905</a> Class&lt;?&gt; cls = command.getClass();
<a class="jxr_linenumber" name="L1906" href="#L1906">1906</a> String declaredName = <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L1907" href="#L1907">1907</a> String declaredSeparator = <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L1908" href="#L1908">1908</a> <strong class="jxr_keyword">boolean</strong> hasCommandAnnotation = false;
<a class="jxr_linenumber" name="L1909" href="#L1909">1909</a> <strong class="jxr_keyword">while</strong> (cls != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L1910" href="#L1910">1910</a> init(cls, requiredFields, optionName2Field, singleCharOption2Field, positionalParametersFields);
<a class="jxr_linenumber" name="L1911" href="#L1911">1911</a> <strong class="jxr_keyword">if</strong> (cls.isAnnotationPresent(Command.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L1912" href="#L1912">1912</a> hasCommandAnnotation = <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L1913" href="#L1913">1913</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Command</a> cmd = cls.getAnnotation(Command.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L1914" href="#L1914">1914</a> declaredSeparator = (declaredSeparator == <strong class="jxr_keyword">null</strong>) ? cmd.separator() : declaredSeparator;
<a class="jxr_linenumber" name="L1915" href="#L1915">1915</a> declaredName = (declaredName == <strong class="jxr_keyword">null</strong>) ? cmd.name() : declaredName;
<a class="jxr_linenumber" name="L1916" href="#L1916">1916</a> CommandLine.<strong class="jxr_keyword">this</strong>.versionLines.addAll(Arrays.asList(cmd.version()));
<a class="jxr_linenumber" name="L1917" href="#L1917">1917</a>
<a class="jxr_linenumber" name="L1918" href="#L1918">1918</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Class&lt;?&gt; sub : cmd.subcommands()) {
<a class="jxr_linenumber" name="L1919" href="#L1919">1919</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Command</a> subCommand = sub.getAnnotation(Command.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L1920" href="#L1920">1920</a> <strong class="jxr_keyword">if</strong> (subCommand == <strong class="jxr_keyword">null</strong> || Help.DEFAULT_COMMAND_NAME.equals(subCommand.name())) {
<a class="jxr_linenumber" name="L1921" href="#L1921">1921</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InitializationException</a>(<span class="jxr_string">"Subcommand "</span> + sub.getName() +
<a class="jxr_linenumber" name="L1922" href="#L1922">1922</a> <span class="jxr_string">" is missing the mandatory @Command annotation with a 'name' attribute"</span>);
<a class="jxr_linenumber" name="L1923" href="#L1923">1923</a> }
<a class="jxr_linenumber" name="L1924" href="#L1924">1924</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L1925" href="#L1925">1925</a> <strong class="jxr_keyword">final</strong> Constructor&lt;?&gt; constructor = sub.getDeclaredConstructor();
<a class="jxr_linenumber" name="L1926" href="#L1926">1926</a> constructor.setAccessible(<strong class="jxr_keyword">true</strong>);
<a class="jxr_linenumber" name="L1927" href="#L1927">1927</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine = toCommandLine(constructor.newInstance());
<a class="jxr_linenumber" name="L1928" href="#L1928">1928</a> commandLine.parent = CommandLine.<strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L1929" href="#L1929">1929</a> commands.put(subCommand.name(), commandLine);
<a class="jxr_linenumber" name="L1930" href="#L1930">1930</a> }
<a class="jxr_linenumber" name="L1931" href="#L1931">1931</a> <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> InitializationException ex) { <strong class="jxr_keyword">throw</strong> ex; }
<a class="jxr_linenumber" name="L1932" href="#L1932">1932</a> <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> NoSuchMethodException ex) { <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> InitializationException(<span class="jxr_string">"Cannot instantiate subcommand "</span> +
<a class="jxr_linenumber" name="L1933" href="#L1933">1933</a> sub.getName() + <span class="jxr_string">": the class has no constructor"</span>, ex); }
<a class="jxr_linenumber" name="L1934" href="#L1934">1934</a> <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ex) {
<a class="jxr_linenumber" name="L1935" href="#L1935">1935</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InitializationException</a>(<span class="jxr_string">"Could not instantiate and add subcommand "</span> +
<a class="jxr_linenumber" name="L1936" href="#L1936">1936</a> sub.getName() + <span class="jxr_string">": "</span> + ex, ex);
<a class="jxr_linenumber" name="L1937" href="#L1937">1937</a> }
<a class="jxr_linenumber" name="L1938" href="#L1938">1938</a> }
<a class="jxr_linenumber" name="L1939" href="#L1939">1939</a> }
<a class="jxr_linenumber" name="L1940" href="#L1940">1940</a> cls = cls.getSuperclass();
<a class="jxr_linenumber" name="L1941" href="#L1941">1941</a> }
<a class="jxr_linenumber" name="L1942" href="#L1942">1942</a> separator = declaredSeparator != <strong class="jxr_keyword">null</strong> ? declaredSeparator : separator;
<a class="jxr_linenumber" name="L1943" href="#L1943">1943</a> CommandLine.<strong class="jxr_keyword">this</strong>.commandName = declaredName != <strong class="jxr_keyword">null</strong> ? declaredName : CommandLine.<strong class="jxr_keyword">this</strong>.commandName;
<a class="jxr_linenumber" name="L1944" href="#L1944">1944</a> Collections.sort(positionalParametersFields, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PositionalParametersSorter</a>());
<a class="jxr_linenumber" name="L1945" href="#L1945">1945</a> validatePositionalParameters(positionalParametersFields);
<a class="jxr_linenumber" name="L1946" href="#L1946">1946</a>
<a class="jxr_linenumber" name="L1947" href="#L1947">1947</a> <strong class="jxr_keyword">if</strong> (positionalParametersFields.isEmpty() &amp;&amp; optionName2Field.isEmpty() &amp;&amp; !hasCommandAnnotation) {
<a class="jxr_linenumber" name="L1948" href="#L1948">1948</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InitializationException</a>(command + <span class="jxr_string">" ("</span> + command.getClass() +
<a class="jxr_linenumber" name="L1949" href="#L1949">1949</a> <span class="jxr_string">") is not a command: it has no @Command, @Option or @Parameters annotations"</span>);
<a class="jxr_linenumber" name="L1950" href="#L1950">1950</a> }
<a class="jxr_linenumber" name="L1951" href="#L1951">1951</a> }
<a class="jxr_linenumber" name="L1952" href="#L1952">1952</a>
<a class="jxr_linenumber" name="L1953" href="#L1953">1953</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L1954" href="#L1954">1954</a> <em class="jxr_javadoccomment"> * Entry point into parsing command line arguments.</em>
<a class="jxr_linenumber" name="L1955" href="#L1955">1955</a> <em class="jxr_javadoccomment"> * @param args the command line arguments</em>
<a class="jxr_linenumber" name="L1956" href="#L1956">1956</a> <em class="jxr_javadoccomment"> * @return a list with all commands and subcommands initialized by this method</em>
<a class="jxr_linenumber" name="L1957" href="#L1957">1957</a> <em class="jxr_javadoccomment"> * @throws ParameterException if the specified command line arguments are invalid</em>
<a class="jxr_linenumber" name="L1958" href="#L1958">1958</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L1959" href="#L1959">1959</a> List&lt;CommandLine&gt; parse(<strong class="jxr_keyword">final</strong> String... args) {
<a class="jxr_linenumber" name="L1960" href="#L1960">1960</a> Assert.notNull(args, <span class="jxr_string">"argument array"</span>);
<a class="jxr_linenumber" name="L1961" href="#L1961">1961</a> <strong class="jxr_keyword">if</strong> (tracer.isInfo()) {tracer.info(<span class="jxr_string">"Parsing %d command line args %s%n"</span>, args.length, Arrays.toString(args));}
<a class="jxr_linenumber" name="L1962" href="#L1962">1962</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; arguments = <strong class="jxr_keyword">new</strong> Stack&lt;String&gt;();
<a class="jxr_linenumber" name="L1963" href="#L1963">1963</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = args.length - 1; i &gt;= 0; i--) {
<a class="jxr_linenumber" name="L1964" href="#L1964">1964</a> arguments.push(args[i]);
<a class="jxr_linenumber" name="L1965" href="#L1965">1965</a> }
<a class="jxr_linenumber" name="L1966" href="#L1966">1966</a> <strong class="jxr_keyword">final</strong> List&lt;CommandLine&gt; result = <strong class="jxr_keyword">new</strong> ArrayList&lt;CommandLine&gt;();
<a class="jxr_linenumber" name="L1967" href="#L1967">1967</a> parse(result, arguments, args);
<a class="jxr_linenumber" name="L1968" href="#L1968">1968</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L1969" href="#L1969">1969</a> }
<a class="jxr_linenumber" name="L1970" href="#L1970">1970</a>
<a class="jxr_linenumber" name="L1971" href="#L1971">1971</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> parse(<strong class="jxr_keyword">final</strong> List&lt;CommandLine&gt; parsedCommands, <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; argumentStack, <strong class="jxr_keyword">final</strong> String[] originalArgs) {
<a class="jxr_linenumber" name="L1972" href="#L1972">1972</a> <em class="jxr_comment">// first reset any state in case this CommandLine instance is being reused</em>
<a class="jxr_linenumber" name="L1973" href="#L1973">1973</a> isHelpRequested = false;
<a class="jxr_linenumber" name="L1974" href="#L1974">1974</a> CommandLine.<strong class="jxr_keyword">this</strong>.versionHelpRequested = false;
<a class="jxr_linenumber" name="L1975" href="#L1975">1975</a> CommandLine.<strong class="jxr_keyword">this</strong>.usageHelpRequested = false;
<a class="jxr_linenumber" name="L1976" href="#L1976">1976</a>
<a class="jxr_linenumber" name="L1977" href="#L1977">1977</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; cmdClass = <strong class="jxr_keyword">this</strong>.command.getClass();
<a class="jxr_linenumber" name="L1978" href="#L1978">1978</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Initializing %s: %d options, %d positional parameters, %d required, %d subcommands.%n"</span>, cmdClass.getName(), <strong class="jxr_keyword">new</strong> HashSet&lt;Field&gt;(optionName2Field.values()).size(), positionalParametersFields.size(), requiredFields.size(), commands.size());}
<a class="jxr_linenumber" name="L1979" href="#L1979">1979</a> parsedCommands.add(CommandLine.<strong class="jxr_keyword">this</strong>);
<a class="jxr_linenumber" name="L1980" href="#L1980">1980</a> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; required = <strong class="jxr_keyword">new</strong> ArrayList&lt;Field&gt;(requiredFields);
<a class="jxr_linenumber" name="L1981" href="#L1981">1981</a> <strong class="jxr_keyword">final</strong> Set&lt;Field&gt; initialized = <strong class="jxr_keyword">new</strong> HashSet&lt;Field&gt;();
<a class="jxr_linenumber" name="L1982" href="#L1982">1982</a> Collections.sort(required, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PositionalParametersSorter</a>());
<a class="jxr_linenumber" name="L1983" href="#L1983">1983</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L1984" href="#L1984">1984</a> processArguments(parsedCommands, argumentStack, required, initialized, originalArgs);
<a class="jxr_linenumber" name="L1985" href="#L1985">1985</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> ParameterException ex) {
<a class="jxr_linenumber" name="L1986" href="#L1986">1986</a> <strong class="jxr_keyword">throw</strong> ex;
<a class="jxr_linenumber" name="L1987" href="#L1987">1987</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ex) {
<a class="jxr_linenumber" name="L1988" href="#L1988">1988</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> offendingArgIndex = originalArgs.length - argumentStack.size() - 1;
<a class="jxr_linenumber" name="L1989" href="#L1989">1989</a> <strong class="jxr_keyword">final</strong> String arg = offendingArgIndex &gt;= 0 &amp;&amp; offendingArgIndex &lt; originalArgs.length ? originalArgs[offendingArgIndex] : <span class="jxr_string">"?"</span>;
<a class="jxr_linenumber" name="L1990" href="#L1990">1990</a> <strong class="jxr_keyword">throw</strong> ParameterException.create(CommandLine.<strong class="jxr_keyword">this</strong>, ex, arg, offendingArgIndex, originalArgs);
<a class="jxr_linenumber" name="L1991" href="#L1991">1991</a> }
<a class="jxr_linenumber" name="L1992" href="#L1992">1992</a> <strong class="jxr_keyword">if</strong> (!isAnyHelpRequested() &amp;&amp; !required.isEmpty()) {
<a class="jxr_linenumber" name="L1993" href="#L1993">1993</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field missing : required) {
<a class="jxr_linenumber" name="L1994" href="#L1994">1994</a> <strong class="jxr_keyword">if</strong> (missing.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L1995" href="#L1995">1995</a> <strong class="jxr_keyword">throw</strong> MissingParameterException.create(CommandLine.<strong class="jxr_keyword">this</strong>, required, separator);
<a class="jxr_linenumber" name="L1996" href="#L1996">1996</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L1997" href="#L1997">1997</a> assertNoMissingParameters(missing, Range.parameterArity(missing).min, argumentStack);
<a class="jxr_linenumber" name="L1998" href="#L1998">1998</a> }
<a class="jxr_linenumber" name="L1999" href="#L1999">1999</a> }
<a class="jxr_linenumber" name="L2000" href="#L2000">2000</a> }
<a class="jxr_linenumber" name="L2001" href="#L2001">2001</a> <strong class="jxr_keyword">if</strong> (!unmatchedArguments.isEmpty()) {
<a class="jxr_linenumber" name="L2002" href="#L2002">2002</a> <strong class="jxr_keyword">if</strong> (!isUnmatchedArgumentsAllowed()) { <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> UnmatchedArgumentException(CommandLine.<strong class="jxr_keyword">this</strong>, unmatchedArguments); }
<a class="jxr_linenumber" name="L2003" href="#L2003">2003</a> <strong class="jxr_keyword">if</strong> (tracer.isWarn()) { tracer.warn(<span class="jxr_string">"Unmatched arguments: %s%n"</span>, unmatchedArguments); }
<a class="jxr_linenumber" name="L2004" href="#L2004">2004</a> }
<a class="jxr_linenumber" name="L2005" href="#L2005">2005</a> }
<a class="jxr_linenumber" name="L2006" href="#L2006">2006</a>
<a class="jxr_linenumber" name="L2007" href="#L2007">2007</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> processArguments(<strong class="jxr_keyword">final</strong> List&lt;CommandLine&gt; parsedCommands,
<a class="jxr_linenumber" name="L2008" href="#L2008">2008</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2009" href="#L2009">2009</a> <strong class="jxr_keyword">final</strong> Collection&lt;Field&gt; required,
<a class="jxr_linenumber" name="L2010" href="#L2010">2010</a> <strong class="jxr_keyword">final</strong> Set&lt;Field&gt; initialized,
<a class="jxr_linenumber" name="L2011" href="#L2011">2011</a> <strong class="jxr_keyword">final</strong> String[] originalArgs) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2012" href="#L2012">2012</a> <em class="jxr_comment">// arg must be one of:</em>
<a class="jxr_linenumber" name="L2013" href="#L2013">2013</a> <em class="jxr_comment">// 1. the "--" double dash separating options from positional arguments</em>
<a class="jxr_linenumber" name="L2014" href="#L2014">2014</a> <em class="jxr_comment">// 1. a stand-alone flag, like "-v" or "--verbose": no value required, must map to boolean or Boolean field</em>
<a class="jxr_linenumber" name="L2015" href="#L2015">2015</a> <em class="jxr_comment">// 2. a short option followed by an argument, like "-f file" or "-ffile": may map to any type of field</em>
<a class="jxr_linenumber" name="L2016" href="#L2016">2016</a> <em class="jxr_comment">// 3. a long option followed by an argument, like "-file out.txt" or "-file=out.txt"</em>
<a class="jxr_linenumber" name="L2017" href="#L2017">2017</a> <em class="jxr_comment">// 3. one or more remaining arguments without any associated options. Must be the last in the list.</em>
<a class="jxr_linenumber" name="L2018" href="#L2018">2018</a> <em class="jxr_comment">// 4. a combination of stand-alone options, like "-vxr". Equivalent to "-v -x -r", "-v true -x true -r true"</em>
<a class="jxr_linenumber" name="L2019" href="#L2019">2019</a> <em class="jxr_comment">// 5. a combination of stand-alone options and one option with an argument, like "-vxrffile"</em>
<a class="jxr_linenumber" name="L2020" href="#L2020">2020</a>
<a class="jxr_linenumber" name="L2021" href="#L2021">2021</a> <strong class="jxr_keyword">while</strong> (!args.isEmpty()) {
<a class="jxr_linenumber" name="L2022" href="#L2022">2022</a> String arg = args.pop();
<a class="jxr_linenumber" name="L2023" href="#L2023">2023</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Processing argument '%s'. Remainder=%s%n"</span>, arg, reverse((Stack&lt;String&gt;) args.clone()));}
<a class="jxr_linenumber" name="L2024" href="#L2024">2024</a>
<a class="jxr_linenumber" name="L2025" href="#L2025">2025</a> <em class="jxr_comment">// Double-dash separates options from positional arguments.</em>
<a class="jxr_linenumber" name="L2026" href="#L2026">2026</a> <em class="jxr_comment">// If found, then interpret the remaining args as positional parameters.</em>
<a class="jxr_linenumber" name="L2027" href="#L2027">2027</a> <strong class="jxr_keyword">if</strong> (<span class="jxr_string">"--"</span>.equals(arg)) {
<a class="jxr_linenumber" name="L2028" href="#L2028">2028</a> tracer.info(<span class="jxr_string">"Found end-of-options delimiter '--'. Treating remainder as positional parameters.%n"</span>);
<a class="jxr_linenumber" name="L2029" href="#L2029">2029</a> processRemainderAsPositionalParameters(required, initialized, args);
<a class="jxr_linenumber" name="L2030" href="#L2030">2030</a> <strong class="jxr_keyword">return</strong>; <em class="jxr_comment">// we are done</em>
<a class="jxr_linenumber" name="L2031" href="#L2031">2031</a> }
<a class="jxr_linenumber" name="L2032" href="#L2032">2032</a>
<a class="jxr_linenumber" name="L2033" href="#L2033">2033</a> <em class="jxr_comment">// if we find another command, we are done with the current command</em>
<a class="jxr_linenumber" name="L2034" href="#L2034">2034</a> <strong class="jxr_keyword">if</strong> (commands.containsKey(arg)) {
<a class="jxr_linenumber" name="L2035" href="#L2035">2035</a> <strong class="jxr_keyword">if</strong> (!isHelpRequested &amp;&amp; !required.isEmpty()) { <em class="jxr_comment">// ensure current command portion is valid</em>
<a class="jxr_linenumber" name="L2036" href="#L2036">2036</a> <strong class="jxr_keyword">throw</strong> MissingParameterException.create(CommandLine.<strong class="jxr_keyword">this</strong>, required, separator);
<a class="jxr_linenumber" name="L2037" href="#L2037">2037</a> }
<a class="jxr_linenumber" name="L2038" href="#L2038">2038</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Found subcommand '%s' (%s)%n"</span>, arg, commands.get(arg).interpreter.command.getClass().getName());}
<a class="jxr_linenumber" name="L2039" href="#L2039">2039</a> commands.get(arg).interpreter.parse(parsedCommands, args, originalArgs);
<a class="jxr_linenumber" name="L2040" href="#L2040">2040</a> <strong class="jxr_keyword">return</strong>; <em class="jxr_comment">// remainder done by the command</em>
<a class="jxr_linenumber" name="L2041" href="#L2041">2041</a> }
<a class="jxr_linenumber" name="L2042" href="#L2042">2042</a>
<a class="jxr_linenumber" name="L2043" href="#L2043">2043</a> <em class="jxr_comment">// First try to interpret the argument as a single option (as opposed to a compact group of options).</em>
<a class="jxr_linenumber" name="L2044" href="#L2044">2044</a> <em class="jxr_comment">// A single option may be without option parameters, like "-v" or "--verbose" (a boolean value),</em>
<a class="jxr_linenumber" name="L2045" href="#L2045">2045</a> <em class="jxr_comment">// or an option may have one or more option parameters.</em>
<a class="jxr_linenumber" name="L2046" href="#L2046">2046</a> <em class="jxr_comment">// A parameter may be attached to the option.</em>
<a class="jxr_linenumber" name="L2047" href="#L2047">2047</a> <strong class="jxr_keyword">boolean</strong> paramAttachedToOption = false;
<a class="jxr_linenumber" name="L2048" href="#L2048">2048</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> separatorIndex = arg.indexOf(separator);
<a class="jxr_linenumber" name="L2049" href="#L2049">2049</a> <strong class="jxr_keyword">if</strong> (separatorIndex &gt; 0) {
<a class="jxr_linenumber" name="L2050" href="#L2050">2050</a> <strong class="jxr_keyword">final</strong> String key = arg.substring(0, separatorIndex);
<a class="jxr_linenumber" name="L2051" href="#L2051">2051</a> <em class="jxr_comment">// be greedy. Consume the whole arg as an option if possible.</em>
<a class="jxr_linenumber" name="L2052" href="#L2052">2052</a> <strong class="jxr_keyword">if</strong> (optionName2Field.containsKey(key) &amp;&amp; !optionName2Field.containsKey(arg)) {
<a class="jxr_linenumber" name="L2053" href="#L2053">2053</a> paramAttachedToOption = <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L2054" href="#L2054">2054</a> <strong class="jxr_keyword">final</strong> String optionParam = arg.substring(separatorIndex + separator.length());
<a class="jxr_linenumber" name="L2055" href="#L2055">2055</a> args.push(optionParam);
<a class="jxr_linenumber" name="L2056" href="#L2056">2056</a> arg = key;
<a class="jxr_linenumber" name="L2057" href="#L2057">2057</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Separated '%s' option from '%s' option parameter%n"</span>, key, optionParam);}
<a class="jxr_linenumber" name="L2058" href="#L2058">2058</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2059" href="#L2059">2059</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"'%s' contains separator '%s' but '%s' is not a known option%n"</span>, arg, separator, key);}
<a class="jxr_linenumber" name="L2060" href="#L2060">2060</a> }
<a class="jxr_linenumber" name="L2061" href="#L2061">2061</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2062" href="#L2062">2062</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"'%s' cannot be separated into &lt;option&gt;%s&lt;option-parameter&gt;%n"</span>, arg, separator);}
<a class="jxr_linenumber" name="L2063" href="#L2063">2063</a> }
<a class="jxr_linenumber" name="L2064" href="#L2064">2064</a> <strong class="jxr_keyword">if</strong> (optionName2Field.containsKey(arg)) {
<a class="jxr_linenumber" name="L2065" href="#L2065">2065</a> processStandaloneOption(required, initialized, arg, args, paramAttachedToOption);
<a class="jxr_linenumber" name="L2066" href="#L2066">2066</a> }
<a class="jxr_linenumber" name="L2067" href="#L2067">2067</a> <em class="jxr_comment">// Compact (single-letter) options can be grouped with other options or with an argument.</em>
<a class="jxr_linenumber" name="L2068" href="#L2068">2068</a> <em class="jxr_comment">// only single-letter options can be combined with other options or with an argument</em>
<a class="jxr_linenumber" name="L2069" href="#L2069">2069</a> <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (arg.length() &gt; 2 &amp;&amp; arg.startsWith(<span class="jxr_string">"-"</span>)) {
<a class="jxr_linenumber" name="L2070" href="#L2070">2070</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Trying to process '%s' as clustered short options%n"</span>, arg, args);}
<a class="jxr_linenumber" name="L2071" href="#L2071">2071</a> processClusteredShortOptions(required, initialized, arg, args);
<a class="jxr_linenumber" name="L2072" href="#L2072">2072</a> }
<a class="jxr_linenumber" name="L2073" href="#L2073">2073</a> <em class="jxr_comment">// The argument could not be interpreted as an option.</em>
<a class="jxr_linenumber" name="L2074" href="#L2074">2074</a> <em class="jxr_comment">// We take this to mean that the remainder are positional arguments</em>
<a class="jxr_linenumber" name="L2075" href="#L2075">2075</a> <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2076" href="#L2076">2076</a> args.push(arg);
<a class="jxr_linenumber" name="L2077" href="#L2077">2077</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Could not find option '%s', deciding whether to treat as unmatched option or positional parameter...%n"</span>, arg);}
<a class="jxr_linenumber" name="L2078" href="#L2078">2078</a> <strong class="jxr_keyword">if</strong> (resemblesOption(arg)) { handleUnmatchedArguments(args.pop()); <strong class="jxr_keyword">continue</strong>; } <em class="jxr_comment">// #149</em>
<a class="jxr_linenumber" name="L2079" href="#L2079">2079</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"No option named '%s' found. Processing remainder as positional parameters%n"</span>, arg);}
<a class="jxr_linenumber" name="L2080" href="#L2080">2080</a> processPositionalParameter(required, initialized, args);
<a class="jxr_linenumber" name="L2081" href="#L2081">2081</a> }
<a class="jxr_linenumber" name="L2082" href="#L2082">2082</a> }
<a class="jxr_linenumber" name="L2083" href="#L2083">2083</a> }
<a class="jxr_linenumber" name="L2084" href="#L2084">2084</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> resemblesOption(<strong class="jxr_keyword">final</strong> String arg) {
<a class="jxr_linenumber" name="L2085" href="#L2085">2085</a> <strong class="jxr_keyword">int</strong> count = 0;
<a class="jxr_linenumber" name="L2086" href="#L2086">2086</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> String optionName : optionName2Field.keySet()) {
<a class="jxr_linenumber" name="L2087" href="#L2087">2087</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; arg.length(); i++) {
<a class="jxr_linenumber" name="L2088" href="#L2088">2088</a> <strong class="jxr_keyword">if</strong> (optionName.length() &gt; i &amp;&amp; arg.charAt(i) == optionName.charAt(i)) { count++; } <strong class="jxr_keyword">else</strong> { <strong class="jxr_keyword">break</strong>; }
<a class="jxr_linenumber" name="L2089" href="#L2089">2089</a> }
<a class="jxr_linenumber" name="L2090" href="#L2090">2090</a> }
<a class="jxr_linenumber" name="L2091" href="#L2091">2091</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> result = count &gt; 0 &amp;&amp; count * 10 &gt;= optionName2Field.size() * 9; <em class="jxr_comment">// at least one prefix char in common with 9 out of 10 options</em>
<a class="jxr_linenumber" name="L2092" href="#L2092">2092</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"%s %s an option: %d matching prefix chars out of %d option names%n"</span>, arg, (result ? <span class="jxr_string">"resembles"</span> : <span class="jxr_string">"doesn't resemble"</span>), count, optionName2Field.size());}
<a class="jxr_linenumber" name="L2093" href="#L2093">2093</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L2094" href="#L2094">2094</a> }
<a class="jxr_linenumber" name="L2095" href="#L2095">2095</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> handleUnmatchedArguments(<strong class="jxr_keyword">final</strong> String arg) {<strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args = <strong class="jxr_keyword">new</strong> Stack&lt;String&gt;(); args.add(arg); handleUnmatchedArguments(args);}
<a class="jxr_linenumber" name="L2096" href="#L2096">2096</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> handleUnmatchedArguments(<strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args) {
<a class="jxr_linenumber" name="L2097" href="#L2097">2097</a> <strong class="jxr_keyword">while</strong> (!args.isEmpty()) { unmatchedArguments.add(args.pop()); } <em class="jxr_comment">// addAll would give args in reverse order</em>
<a class="jxr_linenumber" name="L2098" href="#L2098">2098</a> }
<a class="jxr_linenumber" name="L2099" href="#L2099">2099</a>
<a class="jxr_linenumber" name="L2100" href="#L2100">2100</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> processRemainderAsPositionalParameters(<strong class="jxr_keyword">final</strong> Collection&lt;Field&gt; required, <strong class="jxr_keyword">final</strong> Set&lt;Field&gt; initialized, <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2101" href="#L2101">2101</a> <strong class="jxr_keyword">while</strong> (!args.empty()) {
<a class="jxr_linenumber" name="L2102" href="#L2102">2102</a> processPositionalParameter(required, initialized, args);
<a class="jxr_linenumber" name="L2103" href="#L2103">2103</a> }
<a class="jxr_linenumber" name="L2104" href="#L2104">2104</a> }
<a class="jxr_linenumber" name="L2105" href="#L2105">2105</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> processPositionalParameter(<strong class="jxr_keyword">final</strong> Collection&lt;Field&gt; required, <strong class="jxr_keyword">final</strong> Set&lt;Field&gt; initialized, <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2106" href="#L2106">2106</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Processing next arg as a positional parameter at index=%d. Remainder=%s%n"</span>, position, reverse((Stack&lt;String&gt;) args.clone()));}
<a class="jxr_linenumber" name="L2107" href="#L2107">2107</a> <strong class="jxr_keyword">int</strong> consumed = 0;
<a class="jxr_linenumber" name="L2108" href="#L2108">2108</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field positionalParam : positionalParametersFields) {
<a class="jxr_linenumber" name="L2109" href="#L2109">2109</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> indexRange = Range.parameterIndex(positionalParam);
<a class="jxr_linenumber" name="L2110" href="#L2110">2110</a> <strong class="jxr_keyword">if</strong> (!indexRange.contains(position)) {
<a class="jxr_linenumber" name="L2111" href="#L2111">2111</a> <strong class="jxr_keyword">continue</strong>;
<a class="jxr_linenumber" name="L2112" href="#L2112">2112</a> }
<a class="jxr_linenumber" name="L2113" href="#L2113">2113</a> @SuppressWarnings(<span class="jxr_string">"unchecked"</span>)
<a class="jxr_linenumber" name="L2114" href="#L2114">2114</a> <strong class="jxr_keyword">final</strong>
<a class="jxr_linenumber" name="L2115" href="#L2115">2115</a> Stack&lt;String&gt; argsCopy = (Stack&lt;String&gt;) args.clone();
<a class="jxr_linenumber" name="L2116" href="#L2116">2116</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity = Range.parameterArity(positionalParam);
<a class="jxr_linenumber" name="L2117" href="#L2117">2117</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Position %d is in index range %s. Trying to assign args to %s, arity=%s%n"</span>, position, indexRange, positionalParam, arity);}
<a class="jxr_linenumber" name="L2118" href="#L2118">2118</a> assertNoMissingParameters(positionalParam, arity.min, argsCopy);
<a class="jxr_linenumber" name="L2119" href="#L2119">2119</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> originalSize = argsCopy.size();
<a class="jxr_linenumber" name="L2120" href="#L2120">2120</a> applyOption(positionalParam, Parameters.<strong class="jxr_keyword">class</strong>, arity, false, argsCopy, initialized, <span class="jxr_string">"args["</span> + indexRange + <span class="jxr_string">"] at position "</span> + position);
<a class="jxr_linenumber" name="L2121" href="#L2121">2121</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> count = originalSize - argsCopy.size();
<a class="jxr_linenumber" name="L2122" href="#L2122">2122</a> <strong class="jxr_keyword">if</strong> (count &gt; 0) { required.remove(positionalParam); }
<a class="jxr_linenumber" name="L2123" href="#L2123">2123</a> consumed = Math.max(consumed, count);
<a class="jxr_linenumber" name="L2124" href="#L2124">2124</a> }
<a class="jxr_linenumber" name="L2125" href="#L2125">2125</a> <em class="jxr_comment">// remove processed args from the stack</em>
<a class="jxr_linenumber" name="L2126" href="#L2126">2126</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; consumed; i++) { args.pop(); }
<a class="jxr_linenumber" name="L2127" href="#L2127">2127</a> position += consumed;
<a class="jxr_linenumber" name="L2128" href="#L2128">2128</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Consumed %d arguments, moving position to index %d.%n"</span>, consumed, position);}
<a class="jxr_linenumber" name="L2129" href="#L2129">2129</a> <strong class="jxr_keyword">if</strong> (consumed == 0 &amp;&amp; !args.isEmpty()) {
<a class="jxr_linenumber" name="L2130" href="#L2130">2130</a> handleUnmatchedArguments(args.pop());
<a class="jxr_linenumber" name="L2131" href="#L2131">2131</a> }
<a class="jxr_linenumber" name="L2132" href="#L2132">2132</a> }
<a class="jxr_linenumber" name="L2133" href="#L2133">2133</a>
<a class="jxr_linenumber" name="L2134" href="#L2134">2134</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> processStandaloneOption(<strong class="jxr_keyword">final</strong> Collection&lt;Field&gt; required,
<a class="jxr_linenumber" name="L2135" href="#L2135">2135</a> <strong class="jxr_keyword">final</strong> Set&lt;Field&gt; initialized,
<a class="jxr_linenumber" name="L2136" href="#L2136">2136</a> <strong class="jxr_keyword">final</strong> String arg,
<a class="jxr_linenumber" name="L2137" href="#L2137">2137</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2138" href="#L2138">2138</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> paramAttachedToKey) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2139" href="#L2139">2139</a> <strong class="jxr_keyword">final</strong> Field field = optionName2Field.get(arg);
<a class="jxr_linenumber" name="L2140" href="#L2140">2140</a> required.remove(field);
<a class="jxr_linenumber" name="L2141" href="#L2141">2141</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity = Range.optionArity(field);
<a class="jxr_linenumber" name="L2142" href="#L2142">2142</a> <strong class="jxr_keyword">if</strong> (paramAttachedToKey) {
<a class="jxr_linenumber" name="L2143" href="#L2143">2143</a> arity = arity.min(Math.max(1, arity.min)); <em class="jxr_comment">// if key=value, minimum arity is at least 1</em>
<a class="jxr_linenumber" name="L2144" href="#L2144">2144</a> }
<a class="jxr_linenumber" name="L2145" href="#L2145">2145</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Found option named '%s': field %s, arity=%s%n"</span>, arg, field, arity);}
<a class="jxr_linenumber" name="L2146" href="#L2146">2146</a> applyOption(field, Option.<strong class="jxr_keyword">class</strong>, arity, paramAttachedToKey, args, initialized, <span class="jxr_string">"option "</span> + arg);
<a class="jxr_linenumber" name="L2147" href="#L2147">2147</a> }
<a class="jxr_linenumber" name="L2148" href="#L2148">2148</a>
<a class="jxr_linenumber" name="L2149" href="#L2149">2149</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> processClusteredShortOptions(<strong class="jxr_keyword">final</strong> Collection&lt;Field&gt; required,
<a class="jxr_linenumber" name="L2150" href="#L2150">2150</a> <strong class="jxr_keyword">final</strong> Set&lt;Field&gt; initialized,
<a class="jxr_linenumber" name="L2151" href="#L2151">2151</a> <strong class="jxr_keyword">final</strong> String arg,
<a class="jxr_linenumber" name="L2152" href="#L2152">2152</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args)
<a class="jxr_linenumber" name="L2153" href="#L2153">2153</a> <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2154" href="#L2154">2154</a> <strong class="jxr_keyword">final</strong> String prefix = arg.substring(0, 1);
<a class="jxr_linenumber" name="L2155" href="#L2155">2155</a> String cluster = arg.substring(1);
<a class="jxr_linenumber" name="L2156" href="#L2156">2156</a> <strong class="jxr_keyword">boolean</strong> paramAttachedToOption = <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L2157" href="#L2157">2157</a> <strong class="jxr_keyword">do</strong> {
<a class="jxr_linenumber" name="L2158" href="#L2158">2158</a> <strong class="jxr_keyword">if</strong> (cluster.length() &gt; 0 &amp;&amp; singleCharOption2Field.containsKey(cluster.charAt(0))) {
<a class="jxr_linenumber" name="L2159" href="#L2159">2159</a> <strong class="jxr_keyword">final</strong> Field field = singleCharOption2Field.get(cluster.charAt(0));
<a class="jxr_linenumber" name="L2160" href="#L2160">2160</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity = Range.optionArity(field);
<a class="jxr_linenumber" name="L2161" href="#L2161">2161</a> <strong class="jxr_keyword">final</strong> String argDescription = <span class="jxr_string">"option "</span> + prefix + cluster.charAt(0);
<a class="jxr_linenumber" name="L2162" href="#L2162">2162</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Found option '%s%s' in %s: field %s, arity=%s%n"</span>, prefix, cluster.charAt(0), arg, field, arity);}
<a class="jxr_linenumber" name="L2163" href="#L2163">2163</a> required.remove(field);
<a class="jxr_linenumber" name="L2164" href="#L2164">2164</a> cluster = cluster.length() &gt; 0 ? cluster.substring(1) : <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L2165" href="#L2165">2165</a> paramAttachedToOption = cluster.length() &gt; 0;
<a class="jxr_linenumber" name="L2166" href="#L2166">2166</a> <strong class="jxr_keyword">if</strong> (cluster.startsWith(separator)) {<em class="jxr_comment">// attached with separator, like -f=FILE or -v=true</em>
<a class="jxr_linenumber" name="L2167" href="#L2167">2167</a> cluster = cluster.substring(separator.length());
<a class="jxr_linenumber" name="L2168" href="#L2168">2168</a> arity = arity.min(Math.max(1, arity.min)); <em class="jxr_comment">// if key=value, minimum arity is at least 1</em>
<a class="jxr_linenumber" name="L2169" href="#L2169">2169</a> }
<a class="jxr_linenumber" name="L2170" href="#L2170">2170</a> <strong class="jxr_keyword">if</strong> (arity.min &gt; 0 &amp;&amp; !empty(cluster)) {
<a class="jxr_linenumber" name="L2171" href="#L2171">2171</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Trying to process '%s' as option parameter%n"</span>, cluster);}
<a class="jxr_linenumber" name="L2172" href="#L2172">2172</a> }
<a class="jxr_linenumber" name="L2173" href="#L2173">2173</a> <em class="jxr_comment">// arity may be &gt;= 1, or</em>
<a class="jxr_linenumber" name="L2174" href="#L2174">2174</a> <em class="jxr_comment">// arity &lt;= 0 &amp;&amp; !cluster.startsWith(separator)</em>
<a class="jxr_linenumber" name="L2175" href="#L2175">2175</a> <em class="jxr_comment">// e.g., boolean @Option("-v", arity=0, varargs=true); arg "-rvTRUE", remainder cluster="TRUE"</em>
<a class="jxr_linenumber" name="L2176" href="#L2176">2176</a> <strong class="jxr_keyword">if</strong> (!empty(cluster)) {
<a class="jxr_linenumber" name="L2177" href="#L2177">2177</a> args.push(cluster); <em class="jxr_comment">// interpret remainder as option parameter</em>
<a class="jxr_linenumber" name="L2178" href="#L2178">2178</a> }
<a class="jxr_linenumber" name="L2179" href="#L2179">2179</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> consumed = applyOption(field, Option.<strong class="jxr_keyword">class</strong>, arity, paramAttachedToOption, args, initialized, argDescription);
<a class="jxr_linenumber" name="L2180" href="#L2180">2180</a> <em class="jxr_comment">// only return if cluster (and maybe more) was consumed, otherwise continue do-while loop</em>
<a class="jxr_linenumber" name="L2181" href="#L2181">2181</a> <strong class="jxr_keyword">if</strong> (empty(cluster) || consumed &gt; 0 || args.isEmpty()) {
<a class="jxr_linenumber" name="L2182" href="#L2182">2182</a> <strong class="jxr_keyword">return</strong>;
<a class="jxr_linenumber" name="L2183" href="#L2183">2183</a> }
<a class="jxr_linenumber" name="L2184" href="#L2184">2184</a> cluster = args.pop();
<a class="jxr_linenumber" name="L2185" href="#L2185">2185</a> } <strong class="jxr_keyword">else</strong> { <em class="jxr_comment">// cluster is empty || cluster.charAt(0) is not a short option key</em>
<a class="jxr_linenumber" name="L2186" href="#L2186">2186</a> <strong class="jxr_keyword">if</strong> (cluster.length() == 0) { <em class="jxr_comment">// we finished parsing a group of short options like -rxv</em>
<a class="jxr_linenumber" name="L2187" href="#L2187">2187</a> <strong class="jxr_keyword">return</strong>; <em class="jxr_comment">// return normally and parse the next arg</em>
<a class="jxr_linenumber" name="L2188" href="#L2188">2188</a> }
<a class="jxr_linenumber" name="L2189" href="#L2189">2189</a> <em class="jxr_comment">// We get here when the remainder of the cluster group is neither an option,</em>
<a class="jxr_linenumber" name="L2190" href="#L2190">2190</a> <em class="jxr_comment">// nor a parameter that the last option could consume.</em>
<a class="jxr_linenumber" name="L2191" href="#L2191">2191</a> <strong class="jxr_keyword">if</strong> (arg.endsWith(cluster)) {
<a class="jxr_linenumber" name="L2192" href="#L2192">2192</a> args.push(paramAttachedToOption ? prefix + cluster : cluster);
<a class="jxr_linenumber" name="L2193" href="#L2193">2193</a> <strong class="jxr_keyword">if</strong> (args.peek().equals(arg)) { <em class="jxr_comment">// #149 be consistent between unmatched short and long options</em>
<a class="jxr_linenumber" name="L2194" href="#L2194">2194</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"Could not match any short options in %s, deciding whether to treat as unmatched option or positional parameter...%n"</span>, arg);}
<a class="jxr_linenumber" name="L2195" href="#L2195">2195</a> <strong class="jxr_keyword">if</strong> (resemblesOption(arg)) { handleUnmatchedArguments(args.pop()); <strong class="jxr_keyword">return</strong>; } <em class="jxr_comment">// #149</em>
<a class="jxr_linenumber" name="L2196" href="#L2196">2196</a> processPositionalParameter(required, initialized, args);
<a class="jxr_linenumber" name="L2197" href="#L2197">2197</a> <strong class="jxr_keyword">return</strong>;
<a class="jxr_linenumber" name="L2198" href="#L2198">2198</a> }
<a class="jxr_linenumber" name="L2199" href="#L2199">2199</a> <em class="jxr_comment">// remainder was part of a clustered group that could not be completely parsed</em>
<a class="jxr_linenumber" name="L2200" href="#L2200">2200</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"No option found for %s in %s%n"</span>, cluster, arg);}
<a class="jxr_linenumber" name="L2201" href="#L2201">2201</a> handleUnmatchedArguments(args.pop());
<a class="jxr_linenumber" name="L2202" href="#L2202">2202</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2203" href="#L2203">2203</a> args.push(cluster);
<a class="jxr_linenumber" name="L2204" href="#L2204">2204</a> <strong class="jxr_keyword">if</strong> (tracer.isDebug()) {tracer.debug(<span class="jxr_string">"%s is not an option parameter for %s%n"</span>, cluster, arg);}
<a class="jxr_linenumber" name="L2205" href="#L2205">2205</a> processPositionalParameter(required, initialized, args);
<a class="jxr_linenumber" name="L2206" href="#L2206">2206</a> }
<a class="jxr_linenumber" name="L2207" href="#L2207">2207</a> <strong class="jxr_keyword">return</strong>;
<a class="jxr_linenumber" name="L2208" href="#L2208">2208</a> }
<a class="jxr_linenumber" name="L2209" href="#L2209">2209</a> } <strong class="jxr_keyword">while</strong> (<strong class="jxr_keyword">true</strong>);
<a class="jxr_linenumber" name="L2210" href="#L2210">2210</a> }
<a class="jxr_linenumber" name="L2211" href="#L2211">2211</a>
<a class="jxr_linenumber" name="L2212" href="#L2212">2212</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> applyOption(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2213" href="#L2213">2213</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; annotation,
<a class="jxr_linenumber" name="L2214" href="#L2214">2214</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2215" href="#L2215">2215</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> valueAttachedToOption,
<a class="jxr_linenumber" name="L2216" href="#L2216">2216</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2217" href="#L2217">2217</a> <strong class="jxr_keyword">final</strong> Set&lt;Field&gt; initialized,
<a class="jxr_linenumber" name="L2218" href="#L2218">2218</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2219" href="#L2219">2219</a> updateHelpRequested(field);
<a class="jxr_linenumber" name="L2220" href="#L2220">2220</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length = args.size();
<a class="jxr_linenumber" name="L2221" href="#L2221">2221</a> assertNoMissingParameters(field, arity.min, args);
<a class="jxr_linenumber" name="L2222" href="#L2222">2222</a>
<a class="jxr_linenumber" name="L2223" href="#L2223">2223</a> Class&lt;?&gt; cls = field.getType();
<a class="jxr_linenumber" name="L2224" href="#L2224">2224</a> <strong class="jxr_keyword">if</strong> (cls.isArray()) {
<a class="jxr_linenumber" name="L2225" href="#L2225">2225</a> <strong class="jxr_keyword">return</strong> applyValuesToArrayField(field, annotation, arity, args, cls, argDescription);
<a class="jxr_linenumber" name="L2226" href="#L2226">2226</a> }
<a class="jxr_linenumber" name="L2227" href="#L2227">2227</a> <strong class="jxr_keyword">if</strong> (Collection.<strong class="jxr_keyword">class</strong>.isAssignableFrom(cls)) {
<a class="jxr_linenumber" name="L2228" href="#L2228">2228</a> <strong class="jxr_keyword">return</strong> applyValuesToCollectionField(field, annotation, arity, args, cls, argDescription);
<a class="jxr_linenumber" name="L2229" href="#L2229">2229</a> }
<a class="jxr_linenumber" name="L2230" href="#L2230">2230</a> <strong class="jxr_keyword">if</strong> (Map.<strong class="jxr_keyword">class</strong>.isAssignableFrom(cls)) {
<a class="jxr_linenumber" name="L2231" href="#L2231">2231</a> <strong class="jxr_keyword">return</strong> applyValuesToMapField(field, annotation, arity, args, cls, argDescription);
<a class="jxr_linenumber" name="L2232" href="#L2232">2232</a> }
<a class="jxr_linenumber" name="L2233" href="#L2233">2233</a> cls = getTypeAttribute(field)[0]; <em class="jxr_comment">// field may be interface/abstract type, use annotation to get concrete type</em>
<a class="jxr_linenumber" name="L2234" href="#L2234">2234</a> <strong class="jxr_keyword">return</strong> applyValueToSingleValuedField(field, arity, args, cls, initialized, argDescription);
<a class="jxr_linenumber" name="L2235" href="#L2235">2235</a> }
<a class="jxr_linenumber" name="L2236" href="#L2236">2236</a>
<a class="jxr_linenumber" name="L2237" href="#L2237">2237</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> applyValueToSingleValuedField(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2238" href="#L2238">2238</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2239" href="#L2239">2239</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2240" href="#L2240">2240</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; cls,
<a class="jxr_linenumber" name="L2241" href="#L2241">2241</a> <strong class="jxr_keyword">final</strong> Set&lt;Field&gt; initialized,
<a class="jxr_linenumber" name="L2242" href="#L2242">2242</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2243" href="#L2243">2243</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> noMoreValues = args.isEmpty();
<a class="jxr_linenumber" name="L2244" href="#L2244">2244</a> String value = args.isEmpty() ? <strong class="jxr_keyword">null</strong> : trim(args.pop()); <em class="jxr_comment">// unquote the value</em>
<a class="jxr_linenumber" name="L2245" href="#L2245">2245</a> <strong class="jxr_keyword">int</strong> result = arity.min; <em class="jxr_comment">// the number or args we need to consume</em>
<a class="jxr_linenumber" name="L2246" href="#L2246">2246</a>
<a class="jxr_linenumber" name="L2247" href="#L2247">2247</a> <em class="jxr_comment">// special logic for booleans: BooleanConverter accepts only "true" or "false".</em>
<a class="jxr_linenumber" name="L2248" href="#L2248">2248</a> <strong class="jxr_keyword">if</strong> ((cls == Boolean.<strong class="jxr_keyword">class</strong> || cls == Boolean.TYPE) &amp;&amp; arity.min &lt;= 0) {
<a class="jxr_linenumber" name="L2249" href="#L2249">2249</a>
<a class="jxr_linenumber" name="L2250" href="#L2250">2250</a> <em class="jxr_comment">// boolean option with arity = 0..1 or 0..*: value MAY be a param</em>
<a class="jxr_linenumber" name="L2251" href="#L2251">2251</a> <strong class="jxr_keyword">if</strong> (arity.max &gt; 0 &amp;&amp; (<span class="jxr_string">"true"</span>.equalsIgnoreCase(value) || <span class="jxr_string">"false"</span>.equalsIgnoreCase(value))) {
<a class="jxr_linenumber" name="L2252" href="#L2252">2252</a> result = 1; <em class="jxr_comment">// if it is a varargs we only consume 1 argument if it is a boolean value</em>
<a class="jxr_linenumber" name="L2253" href="#L2253">2253</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2254" href="#L2254">2254</a> <strong class="jxr_keyword">if</strong> (value != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L2255" href="#L2255">2255</a> args.push(value); <em class="jxr_comment">// we don't consume the value</em>
<a class="jxr_linenumber" name="L2256" href="#L2256">2256</a> }
<a class="jxr_linenumber" name="L2257" href="#L2257">2257</a> <strong class="jxr_keyword">final</strong> Boolean currentValue = (Boolean) field.get(command);
<a class="jxr_linenumber" name="L2258" href="#L2258">2258</a> value = String.valueOf(currentValue == <strong class="jxr_keyword">null</strong> ? <strong class="jxr_keyword">true</strong> : !currentValue); <em class="jxr_comment">// #147 toggle existing boolean value</em>
<a class="jxr_linenumber" name="L2259" href="#L2259">2259</a> }
<a class="jxr_linenumber" name="L2260" href="#L2260">2260</a> }
<a class="jxr_linenumber" name="L2261" href="#L2261">2261</a> <strong class="jxr_keyword">if</strong> (noMoreValues &amp;&amp; value == <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L2262" href="#L2262">2262</a> <strong class="jxr_keyword">return</strong> 0;
<a class="jxr_linenumber" name="L2263" href="#L2263">2263</a> }
<a class="jxr_linenumber" name="L2264" href="#L2264">2264</a> <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; converter = getTypeConverter(cls, field);
<a class="jxr_linenumber" name="L2265" href="#L2265">2265</a> <strong class="jxr_keyword">final</strong> Object newValue = tryConvert(field, -1, converter, value, cls);
<a class="jxr_linenumber" name="L2266" href="#L2266">2266</a> <strong class="jxr_keyword">final</strong> Object oldValue = field.get(command);
<a class="jxr_linenumber" name="L2267" href="#L2267">2267</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TraceLevel</a> level = TraceLevel.INFO;
<a class="jxr_linenumber" name="L2268" href="#L2268">2268</a> String traceMessage = <span class="jxr_string">"Setting %s field '%s.%s' to '%5$s' (was '%4$s') for %6$s%n"</span>;
<a class="jxr_linenumber" name="L2269" href="#L2269">2269</a> <strong class="jxr_keyword">if</strong> (initialized != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L2270" href="#L2270">2270</a> <strong class="jxr_keyword">if</strong> (initialized.contains(field)) {
<a class="jxr_linenumber" name="L2271" href="#L2271">2271</a> <strong class="jxr_keyword">if</strong> (!isOverwrittenOptionsAllowed()) {
<a class="jxr_linenumber" name="L2272" href="#L2272">2272</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">OverwrittenOptionException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, optionDescription(<span class="jxr_string">""</span>, field, 0) + <span class="jxr_string">" should be specified only once"</span>);
<a class="jxr_linenumber" name="L2273" href="#L2273">2273</a> }
<a class="jxr_linenumber" name="L2274" href="#L2274">2274</a> level = TraceLevel.WARN;
<a class="jxr_linenumber" name="L2275" href="#L2275">2275</a> traceMessage = <span class="jxr_string">"Overwriting %s field '%s.%s' value '%s' with '%s' for %s%n"</span>;
<a class="jxr_linenumber" name="L2276" href="#L2276">2276</a> }
<a class="jxr_linenumber" name="L2277" href="#L2277">2277</a> initialized.add(field);
<a class="jxr_linenumber" name="L2278" href="#L2278">2278</a> }
<a class="jxr_linenumber" name="L2279" href="#L2279">2279</a> <strong class="jxr_keyword">if</strong> (tracer.level.isEnabled(level)) { level.print(tracer, traceMessage, field.getType().getSimpleName(),
<a class="jxr_linenumber" name="L2280" href="#L2280">2280</a> field.getDeclaringClass().getSimpleName(), field.getName(), String.valueOf(oldValue), String.valueOf(newValue), argDescription);
<a class="jxr_linenumber" name="L2281" href="#L2281">2281</a> }
<a class="jxr_linenumber" name="L2282" href="#L2282">2282</a> field.set(command, newValue);
<a class="jxr_linenumber" name="L2283" href="#L2283">2283</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L2284" href="#L2284">2284</a> }
<a class="jxr_linenumber" name="L2285" href="#L2285">2285</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> applyValuesToMapField(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2286" href="#L2286">2286</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; annotation,
<a class="jxr_linenumber" name="L2287" href="#L2287">2287</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2288" href="#L2288">2288</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2289" href="#L2289">2289</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; cls,
<a class="jxr_linenumber" name="L2290" href="#L2290">2290</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2291" href="#L2291">2291</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt;[] classes = getTypeAttribute(field);
<a class="jxr_linenumber" name="L2292" href="#L2292">2292</a> <strong class="jxr_keyword">if</strong> (classes.length &lt; 2) { <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> ParameterException(CommandLine.<strong class="jxr_keyword">this</strong>, <span class="jxr_string">"Field "</span> + field + <span class="jxr_string">" needs two types (one for the map key, one for the value) but only has "</span> + classes.length + <span class="jxr_string">" types configured."</span>); }
<a class="jxr_linenumber" name="L2293" href="#L2293">2293</a> <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; keyConverter = getTypeConverter(classes[0], field);
<a class="jxr_linenumber" name="L2294" href="#L2294">2294</a> <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; valueConverter = getTypeConverter(classes[1], field);
<a class="jxr_linenumber" name="L2295" href="#L2295">2295</a> Map&lt;Object, Object&gt; result = (Map&lt;Object, Object&gt;) field.get(command);
<a class="jxr_linenumber" name="L2296" href="#L2296">2296</a> <strong class="jxr_keyword">if</strong> (result == <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L2297" href="#L2297">2297</a> result = createMap(cls);
<a class="jxr_linenumber" name="L2298" href="#L2298">2298</a> field.set(command, result);
<a class="jxr_linenumber" name="L2299" href="#L2299">2299</a> }
<a class="jxr_linenumber" name="L2300" href="#L2300">2300</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> originalSize = result.size();
<a class="jxr_linenumber" name="L2301" href="#L2301">2301</a> consumeMapArguments(field, arity, args, classes, keyConverter, valueConverter, result, argDescription);
<a class="jxr_linenumber" name="L2302" href="#L2302">2302</a> <strong class="jxr_keyword">return</strong> result.size() - originalSize;
<a class="jxr_linenumber" name="L2303" href="#L2303">2303</a> }
<a class="jxr_linenumber" name="L2304" href="#L2304">2304</a>
<a class="jxr_linenumber" name="L2305" href="#L2305">2305</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> consumeMapArguments(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2306" href="#L2306">2306</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2307" href="#L2307">2307</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2308" href="#L2308">2308</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt;[] classes,
<a class="jxr_linenumber" name="L2309" href="#L2309">2309</a> <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; keyConverter,
<a class="jxr_linenumber" name="L2310" href="#L2310">2310</a> <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; valueConverter,
<a class="jxr_linenumber" name="L2311" href="#L2311">2311</a> <strong class="jxr_keyword">final</strong> Map&lt;Object, Object&gt; result,
<a class="jxr_linenumber" name="L2312" href="#L2312">2312</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2313" href="#L2313">2313</a> <em class="jxr_comment">// first do the arity.min mandatory parameters</em>
<a class="jxr_linenumber" name="L2314" href="#L2314">2314</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; arity.min; i++) {
<a class="jxr_linenumber" name="L2315" href="#L2315">2315</a> consumeOneMapArgument(field, arity, args, classes, keyConverter, valueConverter, result, i, argDescription);
<a class="jxr_linenumber" name="L2316" href="#L2316">2316</a> }
<a class="jxr_linenumber" name="L2317" href="#L2317">2317</a> <em class="jxr_comment">// now process the varargs if any</em>
<a class="jxr_linenumber" name="L2318" href="#L2318">2318</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = arity.min; i &lt; arity.max &amp;&amp; !args.isEmpty(); i++) {
<a class="jxr_linenumber" name="L2319" href="#L2319">2319</a> <strong class="jxr_keyword">if</strong> (!field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L2320" href="#L2320">2320</a> <strong class="jxr_keyword">if</strong> (commands.containsKey(args.peek()) || isOption(args.peek())) {
<a class="jxr_linenumber" name="L2321" href="#L2321">2321</a> <strong class="jxr_keyword">return</strong>;
<a class="jxr_linenumber" name="L2322" href="#L2322">2322</a> }
<a class="jxr_linenumber" name="L2323" href="#L2323">2323</a> }
<a class="jxr_linenumber" name="L2324" href="#L2324">2324</a> consumeOneMapArgument(field, arity, args, classes, keyConverter, valueConverter, result, i, argDescription);
<a class="jxr_linenumber" name="L2325" href="#L2325">2325</a> }
<a class="jxr_linenumber" name="L2326" href="#L2326">2326</a> }
<a class="jxr_linenumber" name="L2327" href="#L2327">2327</a>
<a class="jxr_linenumber" name="L2328" href="#L2328">2328</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> consumeOneMapArgument(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2329" href="#L2329">2329</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2330" href="#L2330">2330</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2331" href="#L2331">2331</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt;[] classes,
<a class="jxr_linenumber" name="L2332" href="#L2332">2332</a> <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; keyConverter, <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; valueConverter,
<a class="jxr_linenumber" name="L2333" href="#L2333">2333</a> <strong class="jxr_keyword">final</strong> Map&lt;Object, Object&gt; result,
<a class="jxr_linenumber" name="L2334" href="#L2334">2334</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> index,
<a class="jxr_linenumber" name="L2335" href="#L2335">2335</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2336" href="#L2336">2336</a> <strong class="jxr_keyword">final</strong> String[] values = split(trim(args.pop()), field);
<a class="jxr_linenumber" name="L2337" href="#L2337">2337</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> String value : values) {
<a class="jxr_linenumber" name="L2338" href="#L2338">2338</a> <strong class="jxr_keyword">final</strong> String[] keyValue = value.split(<span class="jxr_string">"="</span>);
<a class="jxr_linenumber" name="L2339" href="#L2339">2339</a> <strong class="jxr_keyword">if</strong> (keyValue.length &lt; 2) {
<a class="jxr_linenumber" name="L2340" href="#L2340">2340</a> <strong class="jxr_keyword">final</strong> String splitRegex = splitRegex(field);
<a class="jxr_linenumber" name="L2341" href="#L2341">2341</a> <strong class="jxr_keyword">if</strong> (splitRegex.length() == 0) {
<a class="jxr_linenumber" name="L2342" href="#L2342">2342</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, <span class="jxr_string">"Value for option "</span> + optionDescription(<span class="jxr_string">""</span>, field,
<a class="jxr_linenumber" name="L2343" href="#L2343">2343</a> 0) + <span class="jxr_string">" should be in KEY=VALUE format but was "</span> + value);
<a class="jxr_linenumber" name="L2344" href="#L2344">2344</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2345" href="#L2345">2345</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, <span class="jxr_string">"Value for option "</span> + optionDescription(<span class="jxr_string">""</span>, field,
<a class="jxr_linenumber" name="L2346" href="#L2346">2346</a> 0) + <span class="jxr_string">" should be in KEY=VALUE["</span> + splitRegex + <span class="jxr_string">"KEY=VALUE]... format but was "</span> + value);
<a class="jxr_linenumber" name="L2347" href="#L2347">2347</a> }
<a class="jxr_linenumber" name="L2348" href="#L2348">2348</a> }
<a class="jxr_linenumber" name="L2349" href="#L2349">2349</a> <strong class="jxr_keyword">final</strong> Object mapKey = tryConvert(field, index, keyConverter, keyValue[0], classes[0]);
<a class="jxr_linenumber" name="L2350" href="#L2350">2350</a> <strong class="jxr_keyword">final</strong> Object mapValue = tryConvert(field, index, valueConverter, keyValue[1], classes[1]);
<a class="jxr_linenumber" name="L2351" href="#L2351">2351</a> result.put(mapKey, mapValue);
<a class="jxr_linenumber" name="L2352" href="#L2352">2352</a> <strong class="jxr_keyword">if</strong> (tracer.isInfo()) {tracer.info(<span class="jxr_string">"Putting [%s : %s] in %s&lt;%s, %s&gt; field '%s.%s' for %s%n"</span>, String.valueOf(mapKey), String.valueOf(mapValue),
<a class="jxr_linenumber" name="L2353" href="#L2353">2353</a> result.getClass().getSimpleName(), classes[0].getSimpleName(), classes[1].getSimpleName(), field.getDeclaringClass().getSimpleName(), field.getName(), argDescription);}
<a class="jxr_linenumber" name="L2354" href="#L2354">2354</a> }
<a class="jxr_linenumber" name="L2355" href="#L2355">2355</a> }
<a class="jxr_linenumber" name="L2356" href="#L2356">2356</a>
<a class="jxr_linenumber" name="L2357" href="#L2357">2357</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> checkMaxArityExceeded(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> remainder, <strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> String[] values) {
<a class="jxr_linenumber" name="L2358" href="#L2358">2358</a> <strong class="jxr_keyword">if</strong> (values.length &lt;= remainder) { <strong class="jxr_keyword">return</strong>; }
<a class="jxr_linenumber" name="L2359" href="#L2359">2359</a> <strong class="jxr_keyword">final</strong> String desc = arity.max == remainder ? <span class="jxr_string">""</span> + remainder : arity + <span class="jxr_string">", remainder="</span> + remainder;
<a class="jxr_linenumber" name="L2360" href="#L2360">2360</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MaxValuesforFieldExceededException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, optionDescription(<span class="jxr_string">""</span>, field, -1) +
<a class="jxr_linenumber" name="L2361" href="#L2361">2361</a> <span class="jxr_string">" max number of values ("</span> + arity.max + <span class="jxr_string">") exceeded: remainder is "</span> + remainder + <span class="jxr_string">" but "</span> +
<a class="jxr_linenumber" name="L2362" href="#L2362">2362</a> values.length + <span class="jxr_string">" values were specified: "</span> + Arrays.toString(values));
<a class="jxr_linenumber" name="L2363" href="#L2363">2363</a> }
<a class="jxr_linenumber" name="L2364" href="#L2364">2364</a>
<a class="jxr_linenumber" name="L2365" href="#L2365">2365</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> applyValuesToArrayField(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2366" href="#L2366">2366</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; annotation,
<a class="jxr_linenumber" name="L2367" href="#L2367">2367</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2368" href="#L2368">2368</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2369" href="#L2369">2369</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; cls,
<a class="jxr_linenumber" name="L2370" href="#L2370">2370</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2371" href="#L2371">2371</a> <strong class="jxr_keyword">final</strong> Object existing = field.get(command);
<a class="jxr_linenumber" name="L2372" href="#L2372">2372</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length = existing == <strong class="jxr_keyword">null</strong> ? 0 : Array.getLength(existing);
<a class="jxr_linenumber" name="L2373" href="#L2373">2373</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; type = getTypeAttribute(field)[0];
<a class="jxr_linenumber" name="L2374" href="#L2374">2374</a> <strong class="jxr_keyword">final</strong> List&lt;Object&gt; converted = consumeArguments(field, annotation, arity, args, type, length, argDescription);
<a class="jxr_linenumber" name="L2375" href="#L2375">2375</a> <strong class="jxr_keyword">final</strong> List&lt;Object&gt; newValues = <strong class="jxr_keyword">new</strong> ArrayList&lt;Object&gt;();
<a class="jxr_linenumber" name="L2376" href="#L2376">2376</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; length; i++) {
<a class="jxr_linenumber" name="L2377" href="#L2377">2377</a> newValues.add(Array.get(existing, i));
<a class="jxr_linenumber" name="L2378" href="#L2378">2378</a> }
<a class="jxr_linenumber" name="L2379" href="#L2379">2379</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Object obj : converted) {
<a class="jxr_linenumber" name="L2380" href="#L2380">2380</a> <strong class="jxr_keyword">if</strong> (obj instanceof Collection&lt;?&gt;) {
<a class="jxr_linenumber" name="L2381" href="#L2381">2381</a> newValues.addAll((Collection&lt;?&gt;) obj);
<a class="jxr_linenumber" name="L2382" href="#L2382">2382</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2383" href="#L2383">2383</a> newValues.add(obj);
<a class="jxr_linenumber" name="L2384" href="#L2384">2384</a> }
<a class="jxr_linenumber" name="L2385" href="#L2385">2385</a> }
<a class="jxr_linenumber" name="L2386" href="#L2386">2386</a> <strong class="jxr_keyword">final</strong> Object array = Array.newInstance(type, newValues.size());
<a class="jxr_linenumber" name="L2387" href="#L2387">2387</a> field.set(command, array);
<a class="jxr_linenumber" name="L2388" href="#L2388">2388</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; newValues.size(); i++) {
<a class="jxr_linenumber" name="L2389" href="#L2389">2389</a> Array.set(array, i, newValues.get(i));
<a class="jxr_linenumber" name="L2390" href="#L2390">2390</a> }
<a class="jxr_linenumber" name="L2391" href="#L2391">2391</a> <strong class="jxr_keyword">return</strong> converted.size(); <em class="jxr_comment">// return how many args were consumed</em>
<a class="jxr_linenumber" name="L2392" href="#L2392">2392</a> }
<a class="jxr_linenumber" name="L2393" href="#L2393">2393</a>
<a class="jxr_linenumber" name="L2394" href="#L2394">2394</a> @SuppressWarnings(<span class="jxr_string">"unchecked"</span>)
<a class="jxr_linenumber" name="L2395" href="#L2395">2395</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> applyValuesToCollectionField(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2396" href="#L2396">2396</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; annotation,
<a class="jxr_linenumber" name="L2397" href="#L2397">2397</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2398" href="#L2398">2398</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2399" href="#L2399">2399</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; cls,
<a class="jxr_linenumber" name="L2400" href="#L2400">2400</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2401" href="#L2401">2401</a> Collection&lt;Object&gt; collection = (Collection&lt;Object&gt;) field.get(command);
<a class="jxr_linenumber" name="L2402" href="#L2402">2402</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; type = getTypeAttribute(field)[0];
<a class="jxr_linenumber" name="L2403" href="#L2403">2403</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length = collection == <strong class="jxr_keyword">null</strong> ? 0 : collection.size();
<a class="jxr_linenumber" name="L2404" href="#L2404">2404</a> <strong class="jxr_keyword">final</strong> List&lt;Object&gt; converted = consumeArguments(field, annotation, arity, args, type, length, argDescription);
<a class="jxr_linenumber" name="L2405" href="#L2405">2405</a> <strong class="jxr_keyword">if</strong> (collection == <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L2406" href="#L2406">2406</a> collection = createCollection(cls);
<a class="jxr_linenumber" name="L2407" href="#L2407">2407</a> field.set(command, collection);
<a class="jxr_linenumber" name="L2408" href="#L2408">2408</a> }
<a class="jxr_linenumber" name="L2409" href="#L2409">2409</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Object element : converted) {
<a class="jxr_linenumber" name="L2410" href="#L2410">2410</a> <strong class="jxr_keyword">if</strong> (element instanceof Collection&lt;?&gt;) {
<a class="jxr_linenumber" name="L2411" href="#L2411">2411</a> collection.addAll((Collection&lt;?&gt;) element);
<a class="jxr_linenumber" name="L2412" href="#L2412">2412</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2413" href="#L2413">2413</a> collection.add(element);
<a class="jxr_linenumber" name="L2414" href="#L2414">2414</a> }
<a class="jxr_linenumber" name="L2415" href="#L2415">2415</a> }
<a class="jxr_linenumber" name="L2416" href="#L2416">2416</a> <strong class="jxr_keyword">return</strong> converted.size();
<a class="jxr_linenumber" name="L2417" href="#L2417">2417</a> }
<a class="jxr_linenumber" name="L2418" href="#L2418">2418</a>
<a class="jxr_linenumber" name="L2419" href="#L2419">2419</a> <strong class="jxr_keyword">private</strong> List&lt;Object&gt; consumeArguments(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2420" href="#L2420">2420</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; annotation,
<a class="jxr_linenumber" name="L2421" href="#L2421">2421</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2422" href="#L2422">2422</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2423" href="#L2423">2423</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; type,
<a class="jxr_linenumber" name="L2424" href="#L2424">2424</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> originalSize,
<a class="jxr_linenumber" name="L2425" href="#L2425">2425</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2426" href="#L2426">2426</a> <strong class="jxr_keyword">final</strong> List&lt;Object&gt; result = <strong class="jxr_keyword">new</strong> ArrayList&lt;Object&gt;();
<a class="jxr_linenumber" name="L2427" href="#L2427">2427</a>
<a class="jxr_linenumber" name="L2428" href="#L2428">2428</a> <em class="jxr_comment">// first do the arity.min mandatory parameters</em>
<a class="jxr_linenumber" name="L2429" href="#L2429">2429</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; arity.min; i++) {
<a class="jxr_linenumber" name="L2430" href="#L2430">2430</a> consumeOneArgument(field, arity, args, type, result, i, originalSize, argDescription);
<a class="jxr_linenumber" name="L2431" href="#L2431">2431</a> }
<a class="jxr_linenumber" name="L2432" href="#L2432">2432</a> <em class="jxr_comment">// now process the varargs if any</em>
<a class="jxr_linenumber" name="L2433" href="#L2433">2433</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = arity.min; i &lt; arity.max &amp;&amp; !args.isEmpty(); i++) {
<a class="jxr_linenumber" name="L2434" href="#L2434">2434</a> <strong class="jxr_keyword">if</strong> (annotation != Parameters.<strong class="jxr_keyword">class</strong>) { <em class="jxr_comment">// for vararg Options, we stop if we encounter '--', a command, or another option</em>
<a class="jxr_linenumber" name="L2435" href="#L2435">2435</a> <strong class="jxr_keyword">if</strong> (commands.containsKey(args.peek()) || isOption(args.peek())) {
<a class="jxr_linenumber" name="L2436" href="#L2436">2436</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L2437" href="#L2437">2437</a> }
<a class="jxr_linenumber" name="L2438" href="#L2438">2438</a> }
<a class="jxr_linenumber" name="L2439" href="#L2439">2439</a> consumeOneArgument(field, arity, args, type, result, i, originalSize, argDescription);
<a class="jxr_linenumber" name="L2440" href="#L2440">2440</a> }
<a class="jxr_linenumber" name="L2441" href="#L2441">2441</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L2442" href="#L2442">2442</a> }
<a class="jxr_linenumber" name="L2443" href="#L2443">2443</a>
<a class="jxr_linenumber" name="L2444" href="#L2444">2444</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> consumeOneArgument(<strong class="jxr_keyword">final</strong> Field field,
<a class="jxr_linenumber" name="L2445" href="#L2445">2445</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity,
<a class="jxr_linenumber" name="L2446" href="#L2446">2446</a> <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args,
<a class="jxr_linenumber" name="L2447" href="#L2447">2447</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt; type,
<a class="jxr_linenumber" name="L2448" href="#L2448">2448</a> <strong class="jxr_keyword">final</strong> List&lt;Object&gt; result,
<a class="jxr_linenumber" name="L2449" href="#L2449">2449</a> <strong class="jxr_keyword">int</strong> index,
<a class="jxr_linenumber" name="L2450" href="#L2450">2450</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> originalSize,
<a class="jxr_linenumber" name="L2451" href="#L2451">2451</a> <strong class="jxr_keyword">final</strong> String argDescription) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2452" href="#L2452">2452</a> <strong class="jxr_keyword">final</strong> String[] values = split(trim(args.pop()), field);
<a class="jxr_linenumber" name="L2453" href="#L2453">2453</a> <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; converter = getTypeConverter(type, field);
<a class="jxr_linenumber" name="L2454" href="#L2454">2454</a>
<a class="jxr_linenumber" name="L2455" href="#L2455">2455</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> j = 0; j &lt; values.length; j++) {
<a class="jxr_linenumber" name="L2456" href="#L2456">2456</a> result.add(tryConvert(field, index, converter, values[j], type));
<a class="jxr_linenumber" name="L2457" href="#L2457">2457</a> <strong class="jxr_keyword">if</strong> (tracer.isInfo()) {
<a class="jxr_linenumber" name="L2458" href="#L2458">2458</a> <strong class="jxr_keyword">if</strong> (field.getType().isArray()) {
<a class="jxr_linenumber" name="L2459" href="#L2459">2459</a> tracer.info(<span class="jxr_string">"Adding [%s] to %s[] field '%s.%s' for %s%n"</span>, String.valueOf(result.get(result.size() - 1)), type.getSimpleName(), field.getDeclaringClass().getSimpleName(), field.getName(), argDescription);
<a class="jxr_linenumber" name="L2460" href="#L2460">2460</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2461" href="#L2461">2461</a> tracer.info(<span class="jxr_string">"Adding [%s] to %s&lt;%s&gt; field '%s.%s' for %s%n"</span>, String.valueOf(result.get(result.size() - 1)), field.getType().getSimpleName(), type.getSimpleName(), field.getDeclaringClass().getSimpleName(), field.getName(), argDescription);
<a class="jxr_linenumber" name="L2462" href="#L2462">2462</a> }
<a class="jxr_linenumber" name="L2463" href="#L2463">2463</a> }
<a class="jxr_linenumber" name="L2464" href="#L2464">2464</a> }
<a class="jxr_linenumber" name="L2465" href="#L2465">2465</a> <em class="jxr_comment">//checkMaxArityExceeded(arity, max, field, values);</em>
<a class="jxr_linenumber" name="L2466" href="#L2466">2466</a> <strong class="jxr_keyword">return</strong> ++index;
<a class="jxr_linenumber" name="L2467" href="#L2467">2467</a> }
<a class="jxr_linenumber" name="L2468" href="#L2468">2468</a>
<a class="jxr_linenumber" name="L2469" href="#L2469">2469</a> <strong class="jxr_keyword">private</strong> String splitRegex(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L2470" href="#L2470">2470</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) { <strong class="jxr_keyword">return</strong> field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).split(); }
<a class="jxr_linenumber" name="L2471" href="#L2471">2471</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>)) { <strong class="jxr_keyword">return</strong> field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).split(); }
<a class="jxr_linenumber" name="L2472" href="#L2472">2472</a> <strong class="jxr_keyword">return</strong> <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L2473" href="#L2473">2473</a> }
<a class="jxr_linenumber" name="L2474" href="#L2474">2474</a> <strong class="jxr_keyword">private</strong> String[] split(<strong class="jxr_keyword">final</strong> String value, <strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L2475" href="#L2475">2475</a> <strong class="jxr_keyword">final</strong> String regex = splitRegex(field);
<a class="jxr_linenumber" name="L2476" href="#L2476">2476</a> <strong class="jxr_keyword">return</strong> regex.length() == 0 ? <strong class="jxr_keyword">new</strong> String[] {value} : value.split(regex);
<a class="jxr_linenumber" name="L2477" href="#L2477">2477</a> }
<a class="jxr_linenumber" name="L2478" href="#L2478">2478</a>
<a class="jxr_linenumber" name="L2479" href="#L2479">2479</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L2480" href="#L2480">2480</a> <em class="jxr_javadoccomment"> * Called when parsing varargs parameters for a multi-value option.</em>
<a class="jxr_linenumber" name="L2481" href="#L2481">2481</a> <em class="jxr_javadoccomment"> * When an option is encountered, the remainder should not be interpreted as vararg elements.</em>
<a class="jxr_linenumber" name="L2482" href="#L2482">2482</a> <em class="jxr_javadoccomment"> * @param arg the string to determine whether it is an option or not</em>
<a class="jxr_linenumber" name="L2483" href="#L2483">2483</a> <em class="jxr_javadoccomment"> * @return true if it is an option, false otherwise</em>
<a class="jxr_linenumber" name="L2484" href="#L2484">2484</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L2485" href="#L2485">2485</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> isOption(<strong class="jxr_keyword">final</strong> String arg) {
<a class="jxr_linenumber" name="L2486" href="#L2486">2486</a> <strong class="jxr_keyword">if</strong> (<span class="jxr_string">"--"</span>.equals(arg)) {
<a class="jxr_linenumber" name="L2487" href="#L2487">2487</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L2488" href="#L2488">2488</a> }
<a class="jxr_linenumber" name="L2489" href="#L2489">2489</a> <em class="jxr_comment">// not just arg prefix: we may be in the middle of parsing -xrvfFILE</em>
<a class="jxr_linenumber" name="L2490" href="#L2490">2490</a> <strong class="jxr_keyword">if</strong> (optionName2Field.containsKey(arg)) { <em class="jxr_comment">// -v or -f or --file (not attached to param or other option)</em>
<a class="jxr_linenumber" name="L2491" href="#L2491">2491</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L2492" href="#L2492">2492</a> }
<a class="jxr_linenumber" name="L2493" href="#L2493">2493</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> separatorIndex = arg.indexOf(separator);
<a class="jxr_linenumber" name="L2494" href="#L2494">2494</a> <strong class="jxr_keyword">if</strong> (separatorIndex &gt; 0) { <em class="jxr_comment">// -f=FILE or --file==FILE (attached to param via separator)</em>
<a class="jxr_linenumber" name="L2495" href="#L2495">2495</a> <strong class="jxr_keyword">if</strong> (optionName2Field.containsKey(arg.substring(0, separatorIndex))) {
<a class="jxr_linenumber" name="L2496" href="#L2496">2496</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
<a class="jxr_linenumber" name="L2497" href="#L2497">2497</a> }
<a class="jxr_linenumber" name="L2498" href="#L2498">2498</a> }
<a class="jxr_linenumber" name="L2499" href="#L2499">2499</a> <strong class="jxr_keyword">return</strong> (arg.length() &gt; 2 &amp;&amp; arg.startsWith(<span class="jxr_string">"-"</span>) &amp;&amp; singleCharOption2Field.containsKey(arg.charAt(1)));
<a class="jxr_linenumber" name="L2500" href="#L2500">2500</a> }
<a class="jxr_linenumber" name="L2501" href="#L2501">2501</a> <strong class="jxr_keyword">private</strong> Object tryConvert(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> index, <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; converter, <strong class="jxr_keyword">final</strong> String value, <strong class="jxr_keyword">final</strong> Class&lt;?&gt; type)
<a class="jxr_linenumber" name="L2502" href="#L2502">2502</a> <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2503" href="#L2503">2503</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L2504" href="#L2504">2504</a> <strong class="jxr_keyword">return</strong> converter.convert(value);
<a class="jxr_linenumber" name="L2505" href="#L2505">2505</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> TypeConversionException ex) {
<a class="jxr_linenumber" name="L2506" href="#L2506">2506</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, ex.getMessage() + optionDescription(<span class="jxr_string">" for "</span>, field, index));
<a class="jxr_linenumber" name="L2507" href="#L2507">2507</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception other) {
<a class="jxr_linenumber" name="L2508" href="#L2508">2508</a> <strong class="jxr_keyword">final</strong> String desc = optionDescription(<span class="jxr_string">" for "</span>, field, index) + <span class="jxr_string">": "</span> + other;
<a class="jxr_linenumber" name="L2509" href="#L2509">2509</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, <span class="jxr_string">"Could not convert '"</span> + value + <span class="jxr_string">"' to "</span> + type.getSimpleName() + desc, other);
<a class="jxr_linenumber" name="L2510" href="#L2510">2510</a> }
<a class="jxr_linenumber" name="L2511" href="#L2511">2511</a> }
<a class="jxr_linenumber" name="L2512" href="#L2512">2512</a>
<a class="jxr_linenumber" name="L2513" href="#L2513">2513</a> <strong class="jxr_keyword">private</strong> String optionDescription(<strong class="jxr_keyword">final</strong> String prefix, <strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> index) {
<a class="jxr_linenumber" name="L2514" href="#L2514">2514</a> <strong class="jxr_keyword">final</strong> Help.IParamLabelRenderer labelRenderer = Help.createMinimalParamLabelRenderer();
<a class="jxr_linenumber" name="L2515" href="#L2515">2515</a> String desc = <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L2516" href="#L2516">2516</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L2517" href="#L2517">2517</a> desc = prefix + <span class="jxr_string">"option '"</span> + field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).names()[0] + <span class="jxr_string">"'"</span>;
<a class="jxr_linenumber" name="L2518" href="#L2518">2518</a> <strong class="jxr_keyword">if</strong> (index &gt;= 0) {
<a class="jxr_linenumber" name="L2519" href="#L2519">2519</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity = Range.optionArity(field);
<a class="jxr_linenumber" name="L2520" href="#L2520">2520</a> <strong class="jxr_keyword">if</strong> (arity.max &gt; 1) {
<a class="jxr_linenumber" name="L2521" href="#L2521">2521</a> desc += <span class="jxr_string">" at index "</span> + index;
<a class="jxr_linenumber" name="L2522" href="#L2522">2522</a> }
<a class="jxr_linenumber" name="L2523" href="#L2523">2523</a> desc += <span class="jxr_string">" ("</span> + labelRenderer.renderParameterLabel(field, Help.Ansi.OFF, Collections.&lt;IStyle&gt;emptyList()) + <span class="jxr_string">")"</span>;
<a class="jxr_linenumber" name="L2524" href="#L2524">2524</a> }
<a class="jxr_linenumber" name="L2525" href="#L2525">2525</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L2526" href="#L2526">2526</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> indexRange = Range.parameterIndex(field);
<a class="jxr_linenumber" name="L2527" href="#L2527">2527</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> label = labelRenderer.renderParameterLabel(field, Help.Ansi.OFF, Collections.&lt;IStyle&gt;emptyList());
<a class="jxr_linenumber" name="L2528" href="#L2528">2528</a> desc = prefix + <span class="jxr_string">"positional parameter at index "</span> + indexRange + <span class="jxr_string">" ("</span> + label + <span class="jxr_string">")"</span>;
<a class="jxr_linenumber" name="L2529" href="#L2529">2529</a> }
<a class="jxr_linenumber" name="L2530" href="#L2530">2530</a> <strong class="jxr_keyword">return</strong> desc;
<a class="jxr_linenumber" name="L2531" href="#L2531">2531</a> }
<a class="jxr_linenumber" name="L2532" href="#L2532">2532</a>
<a class="jxr_linenumber" name="L2533" href="#L2533">2533</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> isAnyHelpRequested() { <strong class="jxr_keyword">return</strong> isHelpRequested || versionHelpRequested || usageHelpRequested; }
<a class="jxr_linenumber" name="L2534" href="#L2534">2534</a>
<a class="jxr_linenumber" name="L2535" href="#L2535">2535</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> updateHelpRequested(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L2536" href="#L2536">2536</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L2537" href="#L2537">2537</a> isHelpRequested |= is(field, <span class="jxr_string">"help"</span>, field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).help());
<a class="jxr_linenumber" name="L2538" href="#L2538">2538</a> CommandLine.<strong class="jxr_keyword">this</strong>.versionHelpRequested |= is(field, <span class="jxr_string">"versionHelp"</span>, field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).versionHelp());
<a class="jxr_linenumber" name="L2539" href="#L2539">2539</a> CommandLine.<strong class="jxr_keyword">this</strong>.usageHelpRequested |= is(field, <span class="jxr_string">"usageHelp"</span>, field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).usageHelp());
<a class="jxr_linenumber" name="L2540" href="#L2540">2540</a> }
<a class="jxr_linenumber" name="L2541" href="#L2541">2541</a> }
<a class="jxr_linenumber" name="L2542" href="#L2542">2542</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> is(<strong class="jxr_keyword">final</strong> Field f, <strong class="jxr_keyword">final</strong> String description, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> value) {
<a class="jxr_linenumber" name="L2543" href="#L2543">2543</a> <strong class="jxr_keyword">if</strong> (value) { <strong class="jxr_keyword">if</strong> (tracer.isInfo()) {tracer.info(<span class="jxr_string">"Field '%s.%s' has '%s' annotation: not validating required fields%n"</span>, f.getDeclaringClass().getSimpleName(), f.getName(), description); }}
<a class="jxr_linenumber" name="L2544" href="#L2544">2544</a> <strong class="jxr_keyword">return</strong> value;
<a class="jxr_linenumber" name="L2545" href="#L2545">2545</a> }
<a class="jxr_linenumber" name="L2546" href="#L2546">2546</a> @SuppressWarnings(<span class="jxr_string">"unchecked"</span>)
<a class="jxr_linenumber" name="L2547" href="#L2547">2547</a> <strong class="jxr_keyword">private</strong> Collection&lt;Object&gt; createCollection(<strong class="jxr_keyword">final</strong> Class&lt;?&gt; collectionClass) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2548" href="#L2548">2548</a> <strong class="jxr_keyword">if</strong> (collectionClass.isInterface()) {
<a class="jxr_linenumber" name="L2549" href="#L2549">2549</a> <strong class="jxr_keyword">if</strong> (List.<strong class="jxr_keyword">class</strong>.isAssignableFrom(collectionClass)) {
<a class="jxr_linenumber" name="L2550" href="#L2550">2550</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> ArrayList&lt;Object&gt;();
<a class="jxr_linenumber" name="L2551" href="#L2551">2551</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (SortedSet.<strong class="jxr_keyword">class</strong>.isAssignableFrom(collectionClass)) {
<a class="jxr_linenumber" name="L2552" href="#L2552">2552</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> TreeSet&lt;Object&gt;();
<a class="jxr_linenumber" name="L2553" href="#L2553">2553</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Set.<strong class="jxr_keyword">class</strong>.isAssignableFrom(collectionClass)) {
<a class="jxr_linenumber" name="L2554" href="#L2554">2554</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> LinkedHashSet&lt;Object&gt;();
<a class="jxr_linenumber" name="L2555" href="#L2555">2555</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Queue.<strong class="jxr_keyword">class</strong>.isAssignableFrom(collectionClass)) {
<a class="jxr_linenumber" name="L2556" href="#L2556">2556</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> LinkedList&lt;Object&gt;(); <em class="jxr_comment">// ArrayDeque is only available since 1.6</em>
<a class="jxr_linenumber" name="L2557" href="#L2557">2557</a> }
<a class="jxr_linenumber" name="L2558" href="#L2558">2558</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> ArrayList&lt;Object&gt;();
<a class="jxr_linenumber" name="L2559" href="#L2559">2559</a> }
<a class="jxr_linenumber" name="L2560" href="#L2560">2560</a> <em class="jxr_comment">// custom Collection implementation class must have default constructor</em>
<a class="jxr_linenumber" name="L2561" href="#L2561">2561</a> <strong class="jxr_keyword">return</strong> (Collection&lt;Object&gt;) collectionClass.newInstance();
<a class="jxr_linenumber" name="L2562" href="#L2562">2562</a> }
<a class="jxr_linenumber" name="L2563" href="#L2563">2563</a> <strong class="jxr_keyword">private</strong> Map&lt;Object, Object&gt; createMap(<strong class="jxr_keyword">final</strong> Class&lt;?&gt; mapClass) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2564" href="#L2564">2564</a> <strong class="jxr_keyword">try</strong> { <em class="jxr_comment">// if it is an implementation class, instantiate it</em>
<a class="jxr_linenumber" name="L2565" href="#L2565">2565</a> <strong class="jxr_keyword">return</strong> (Map&lt;Object, Object&gt;) mapClass.newInstance();
<a class="jxr_linenumber" name="L2566" href="#L2566">2566</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ignored) {}
<a class="jxr_linenumber" name="L2567" href="#L2567">2567</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> LinkedHashMap&lt;Object, Object&gt;();
<a class="jxr_linenumber" name="L2568" href="#L2568">2568</a> }
<a class="jxr_linenumber" name="L2569" href="#L2569">2569</a> <strong class="jxr_keyword">private</strong> ITypeConverter&lt;?&gt; getTypeConverter(<strong class="jxr_keyword">final</strong> Class&lt;?&gt; type, <strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L2570" href="#L2570">2570</a> <strong class="jxr_keyword">final</strong> ITypeConverter&lt;?&gt; result = converterRegistry.get(type);
<a class="jxr_linenumber" name="L2571" href="#L2571">2571</a> <strong class="jxr_keyword">if</strong> (result != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L2572" href="#L2572">2572</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L2573" href="#L2573">2573</a> }
<a class="jxr_linenumber" name="L2574" href="#L2574">2574</a> <strong class="jxr_keyword">if</strong> (type.isEnum()) {
<a class="jxr_linenumber" name="L2575" href="#L2575">2575</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> ITypeConverter&lt;Object&gt;() {
<a class="jxr_linenumber" name="L2576" href="#L2576">2576</a> @Override
<a class="jxr_linenumber" name="L2577" href="#L2577">2577</a> @SuppressWarnings(<span class="jxr_string">"unchecked"</span>)
<a class="jxr_linenumber" name="L2578" href="#L2578">2578</a> <strong class="jxr_keyword">public</strong> Object convert(<strong class="jxr_keyword">final</strong> String value) <strong class="jxr_keyword">throws</strong> Exception {
<a class="jxr_linenumber" name="L2579" href="#L2579">2579</a> <strong class="jxr_keyword">return</strong> Enum.valueOf((Class&lt;Enum&gt;) type, value);
<a class="jxr_linenumber" name="L2580" href="#L2580">2580</a> }
<a class="jxr_linenumber" name="L2581" href="#L2581">2581</a> };
<a class="jxr_linenumber" name="L2582" href="#L2582">2582</a> }
<a class="jxr_linenumber" name="L2583" href="#L2583">2583</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingTypeConverterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, <span class="jxr_string">"No TypeConverter registered for "</span> + type.getName() + <span class="jxr_string">" of field "</span> + field);
<a class="jxr_linenumber" name="L2584" href="#L2584">2584</a> }
<a class="jxr_linenumber" name="L2585" href="#L2585">2585</a>
<a class="jxr_linenumber" name="L2586" href="#L2586">2586</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> assertNoMissingParameters(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> arity, <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args) {
<a class="jxr_linenumber" name="L2587" href="#L2587">2587</a> <strong class="jxr_keyword">if</strong> (arity &gt; args.size()) {
<a class="jxr_linenumber" name="L2588" href="#L2588">2588</a> <strong class="jxr_keyword">if</strong> (arity == 1) {
<a class="jxr_linenumber" name="L2589" href="#L2589">2589</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L2590" href="#L2590">2590</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, <span class="jxr_string">"Missing required parameter for "</span> +
<a class="jxr_linenumber" name="L2591" href="#L2591">2591</a> optionDescription(<span class="jxr_string">""</span>, field, 0));
<a class="jxr_linenumber" name="L2592" href="#L2592">2592</a> }
<a class="jxr_linenumber" name="L2593" href="#L2593">2593</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> indexRange = Range.parameterIndex(field);
<a class="jxr_linenumber" name="L2594" href="#L2594">2594</a> <strong class="jxr_keyword">final</strong> Help.IParamLabelRenderer labelRenderer = Help.createMinimalParamLabelRenderer();
<a class="jxr_linenumber" name="L2595" href="#L2595">2595</a> String sep = <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L2596" href="#L2596">2596</a> String names = <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L2597" href="#L2597">2597</a> <strong class="jxr_keyword">int</strong> count = 0;
<a class="jxr_linenumber" name="L2598" href="#L2598">2598</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = indexRange.min; i &lt; positionalParametersFields.size(); i++) {
<a class="jxr_linenumber" name="L2599" href="#L2599">2599</a> <strong class="jxr_keyword">if</strong> (Range.parameterArity(positionalParametersFields.get(i)).min &gt; 0) {
<a class="jxr_linenumber" name="L2600" href="#L2600">2600</a> names += sep + labelRenderer.renderParameterLabel(positionalParametersFields.get(i),
<a class="jxr_linenumber" name="L2601" href="#L2601">2601</a> Help.Ansi.OFF, Collections.&lt;IStyle&gt;emptyList());
<a class="jxr_linenumber" name="L2602" href="#L2602">2602</a> sep = <span class="jxr_string">", "</span>;
<a class="jxr_linenumber" name="L2603" href="#L2603">2603</a> count++;
<a class="jxr_linenumber" name="L2604" href="#L2604">2604</a> }
<a class="jxr_linenumber" name="L2605" href="#L2605">2605</a> }
<a class="jxr_linenumber" name="L2606" href="#L2606">2606</a> String msg = <span class="jxr_string">"Missing required parameter"</span>;
<a class="jxr_linenumber" name="L2607" href="#L2607">2607</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> paramArity = Range.parameterArity(field);
<a class="jxr_linenumber" name="L2608" href="#L2608">2608</a> <strong class="jxr_keyword">if</strong> (paramArity.isVariable) {
<a class="jxr_linenumber" name="L2609" href="#L2609">2609</a> msg += <span class="jxr_string">"s at positions "</span> + indexRange + <span class="jxr_string">": "</span>;
<a class="jxr_linenumber" name="L2610" href="#L2610">2610</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2611" href="#L2611">2611</a> msg += (count &gt; 1 ? <span class="jxr_string">"s: "</span> : <span class="jxr_string">": "</span>);
<a class="jxr_linenumber" name="L2612" href="#L2612">2612</a> }
<a class="jxr_linenumber" name="L2613" href="#L2613">2613</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, msg + names);
<a class="jxr_linenumber" name="L2614" href="#L2614">2614</a> }
<a class="jxr_linenumber" name="L2615" href="#L2615">2615</a> <strong class="jxr_keyword">if</strong> (args.isEmpty()) {
<a class="jxr_linenumber" name="L2616" href="#L2616">2616</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, optionDescription(<span class="jxr_string">""</span>, field, 0) +
<a class="jxr_linenumber" name="L2617" href="#L2617">2617</a> <span class="jxr_string">" requires at least "</span> + arity + <span class="jxr_string">" values, but none were specified."</span>);
<a class="jxr_linenumber" name="L2618" href="#L2618">2618</a> }
<a class="jxr_linenumber" name="L2619" href="#L2619">2619</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a>(CommandLine.<strong class="jxr_keyword">this</strong>, optionDescription(<span class="jxr_string">""</span>, field, 0) +
<a class="jxr_linenumber" name="L2620" href="#L2620">2620</a> <span class="jxr_string">" requires at least "</span> + arity + <span class="jxr_string">" values, but only "</span> + args.size() + <span class="jxr_string">" were specified: "</span> + reverse(args));
<a class="jxr_linenumber" name="L2621" href="#L2621">2621</a> }
<a class="jxr_linenumber" name="L2622" href="#L2622">2622</a> }
<a class="jxr_linenumber" name="L2623" href="#L2623">2623</a> <strong class="jxr_keyword">private</strong> String trim(<strong class="jxr_keyword">final</strong> String value) {
<a class="jxr_linenumber" name="L2624" href="#L2624">2624</a> <strong class="jxr_keyword">return</strong> unquote(value);
<a class="jxr_linenumber" name="L2625" href="#L2625">2625</a> }
<a class="jxr_linenumber" name="L2626" href="#L2626">2626</a>
<a class="jxr_linenumber" name="L2627" href="#L2627">2627</a> <strong class="jxr_keyword">private</strong> String unquote(<strong class="jxr_keyword">final</strong> String value) {
<a class="jxr_linenumber" name="L2628" href="#L2628">2628</a> <strong class="jxr_keyword">return</strong> value == <strong class="jxr_keyword">null</strong>
<a class="jxr_linenumber" name="L2629" href="#L2629">2629</a> ? <strong class="jxr_keyword">null</strong>
<a class="jxr_linenumber" name="L2630" href="#L2630">2630</a> : (value.length() &gt; 1 &amp;&amp; value.startsWith(<span class="jxr_string">"\&quot;"</span>) &amp;&amp; value.endsWith(<span class="jxr_string">"\&quot;"</span>))
<a class="jxr_linenumber" name="L2631" href="#L2631">2631</a> ? value.substring(1, value.length() - 1)
<a class="jxr_linenumber" name="L2632" href="#L2632">2632</a> : value;
<a class="jxr_linenumber" name="L2633" href="#L2633">2633</a> }
<a class="jxr_linenumber" name="L2634" href="#L2634">2634</a> }
<a class="jxr_linenumber" name="L2635" href="#L2635">2635</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PositionalParametersSorter</a> <strong class="jxr_keyword">implements</strong> Comparator&lt;Field&gt; {
<a class="jxr_linenumber" name="L2636" href="#L2636">2636</a> @Override
<a class="jxr_linenumber" name="L2637" href="#L2637">2637</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> compare(<strong class="jxr_keyword">final</strong> Field o1, <strong class="jxr_keyword">final</strong> Field o2) {
<a class="jxr_linenumber" name="L2638" href="#L2638">2638</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> result = Range.parameterIndex(o1).compareTo(Range.parameterIndex(o2));
<a class="jxr_linenumber" name="L2639" href="#L2639">2639</a> <strong class="jxr_keyword">return</strong> (result == 0) ? Range.parameterArity(o1).compareTo(Range.parameterArity(o2)) : result;
<a class="jxr_linenumber" name="L2640" href="#L2640">2640</a> }
<a class="jxr_linenumber" name="L2641" href="#L2641">2641</a> }
<a class="jxr_linenumber" name="L2642" href="#L2642">2642</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L2643" href="#L2643">2643</a> <em class="jxr_javadoccomment"> * Inner class to group the built-in {@link ITypeConverter} implementations.</em>
<a class="jxr_linenumber" name="L2644" href="#L2644">2644</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L2645" href="#L2645">2645</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">BuiltIn</a> {
<a class="jxr_linenumber" name="L2646" href="#L2646">2646</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PathConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Path&gt; {
<a class="jxr_linenumber" name="L2647" href="#L2647">2647</a> @Override <strong class="jxr_keyword">public</strong> Path convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> Paths.get(value); }
<a class="jxr_linenumber" name="L2648" href="#L2648">2648</a> }
<a class="jxr_linenumber" name="L2649" href="#L2649">2649</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StringConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;String&gt; {
<a class="jxr_linenumber" name="L2650" href="#L2650">2650</a> @Override
<a class="jxr_linenumber" name="L2651" href="#L2651">2651</a> <strong class="jxr_keyword">public</strong> String convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> value; }
<a class="jxr_linenumber" name="L2652" href="#L2652">2652</a> }
<a class="jxr_linenumber" name="L2653" href="#L2653">2653</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StringBuilderConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;StringBuilder&gt; {
<a class="jxr_linenumber" name="L2654" href="#L2654">2654</a> @Override
<a class="jxr_linenumber" name="L2655" href="#L2655">2655</a> <strong class="jxr_keyword">public</strong> StringBuilder convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> StringBuilder(value); }
<a class="jxr_linenumber" name="L2656" href="#L2656">2656</a> }
<a class="jxr_linenumber" name="L2657" href="#L2657">2657</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CharSequenceConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;CharSequence&gt; {
<a class="jxr_linenumber" name="L2658" href="#L2658">2658</a> @Override
<a class="jxr_linenumber" name="L2659" href="#L2659">2659</a> <strong class="jxr_keyword">public</strong> String convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> value; }
<a class="jxr_linenumber" name="L2660" href="#L2660">2660</a> }
<a class="jxr_linenumber" name="L2661" href="#L2661">2661</a> <em class="jxr_javadoccomment">/** Converts text to a {@code Byte} by delegating to {@link Byte#valueOf(String)}.*/</em>
<a class="jxr_linenumber" name="L2662" href="#L2662">2662</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ByteConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Byte&gt; {
<a class="jxr_linenumber" name="L2663" href="#L2663">2663</a> @Override
<a class="jxr_linenumber" name="L2664" href="#L2664">2664</a> <strong class="jxr_keyword">public</strong> Byte convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> Byte.valueOf(value); }
<a class="jxr_linenumber" name="L2665" href="#L2665">2665</a> }
<a class="jxr_linenumber" name="L2666" href="#L2666">2666</a> <em class="jxr_javadoccomment">/** Converts {@code "true"} or {@code "false"} to a {@code Boolean}. Other values result in a ParameterException.*/</em>
<a class="jxr_linenumber" name="L2667" href="#L2667">2667</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">BooleanConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Boolean&gt; {
<a class="jxr_linenumber" name="L2668" href="#L2668">2668</a> @Override
<a class="jxr_linenumber" name="L2669" href="#L2669">2669</a> <strong class="jxr_keyword">public</strong> Boolean convert(<strong class="jxr_keyword">final</strong> String value) {
<a class="jxr_linenumber" name="L2670" href="#L2670">2670</a> <strong class="jxr_keyword">if</strong> (<span class="jxr_string">"true"</span>.equalsIgnoreCase(value) || <span class="jxr_string">"false"</span>.equalsIgnoreCase(value)) {
<a class="jxr_linenumber" name="L2671" href="#L2671">2671</a> <strong class="jxr_keyword">return</strong> Boolean.parseBoolean(value);
<a class="jxr_linenumber" name="L2672" href="#L2672">2672</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L2673" href="#L2673">2673</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TypeConversionException</a>(<span class="jxr_string">"'"</span> + value + <span class="jxr_string">"' is not a boolean"</span>);
<a class="jxr_linenumber" name="L2674" href="#L2674">2674</a> }
<a class="jxr_linenumber" name="L2675" href="#L2675">2675</a> }
<a class="jxr_linenumber" name="L2676" href="#L2676">2676</a> }
<a class="jxr_linenumber" name="L2677" href="#L2677">2677</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CharacterConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Character&gt; {
<a class="jxr_linenumber" name="L2678" href="#L2678">2678</a> @Override
<a class="jxr_linenumber" name="L2679" href="#L2679">2679</a> <strong class="jxr_keyword">public</strong> Character convert(<strong class="jxr_keyword">final</strong> String value) {
<a class="jxr_linenumber" name="L2680" href="#L2680">2680</a> <strong class="jxr_keyword">if</strong> (value.length() &gt; 1) {
<a class="jxr_linenumber" name="L2681" href="#L2681">2681</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TypeConversionException</a>(<span class="jxr_string">"'"</span> + value + <span class="jxr_string">"' is not a single character"</span>);
<a class="jxr_linenumber" name="L2682" href="#L2682">2682</a> }
<a class="jxr_linenumber" name="L2683" href="#L2683">2683</a> <strong class="jxr_keyword">return</strong> value.charAt(0);
<a class="jxr_linenumber" name="L2684" href="#L2684">2684</a> }
<a class="jxr_linenumber" name="L2685" href="#L2685">2685</a> }
<a class="jxr_linenumber" name="L2686" href="#L2686">2686</a> <em class="jxr_javadoccomment">/** Converts text to a {@code Short} by delegating to {@link Short#valueOf(String)}.*/</em>
<a class="jxr_linenumber" name="L2687" href="#L2687">2687</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ShortConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Short&gt; {
<a class="jxr_linenumber" name="L2688" href="#L2688">2688</a> @Override
<a class="jxr_linenumber" name="L2689" href="#L2689">2689</a> <strong class="jxr_keyword">public</strong> Short convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> Short.valueOf(value); }
<a class="jxr_linenumber" name="L2690" href="#L2690">2690</a> }
<a class="jxr_linenumber" name="L2691" href="#L2691">2691</a> <em class="jxr_javadoccomment">/** Converts text to an {@code Integer} by delegating to {@link Integer#valueOf(String)}.*/</em>
<a class="jxr_linenumber" name="L2692" href="#L2692">2692</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IntegerConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Integer&gt; {
<a class="jxr_linenumber" name="L2693" href="#L2693">2693</a> @Override
<a class="jxr_linenumber" name="L2694" href="#L2694">2694</a> <strong class="jxr_keyword">public</strong> Integer convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> Integer.valueOf(value); }
<a class="jxr_linenumber" name="L2695" href="#L2695">2695</a> }
<a class="jxr_linenumber" name="L2696" href="#L2696">2696</a> <em class="jxr_javadoccomment">/** Converts text to a {@code Long} by delegating to {@link Long#valueOf(String)}.*/</em>
<a class="jxr_linenumber" name="L2697" href="#L2697">2697</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">LongConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Long&gt; {
<a class="jxr_linenumber" name="L2698" href="#L2698">2698</a> @Override
<a class="jxr_linenumber" name="L2699" href="#L2699">2699</a> <strong class="jxr_keyword">public</strong> Long convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> Long.valueOf(value); }
<a class="jxr_linenumber" name="L2700" href="#L2700">2700</a> }
<a class="jxr_linenumber" name="L2701" href="#L2701">2701</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">FloatConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Float&gt; {
<a class="jxr_linenumber" name="L2702" href="#L2702">2702</a> @Override
<a class="jxr_linenumber" name="L2703" href="#L2703">2703</a> <strong class="jxr_keyword">public</strong> Float convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> Float.valueOf(value); }
<a class="jxr_linenumber" name="L2704" href="#L2704">2704</a> }
<a class="jxr_linenumber" name="L2705" href="#L2705">2705</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DoubleConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Double&gt; {
<a class="jxr_linenumber" name="L2706" href="#L2706">2706</a> @Override
<a class="jxr_linenumber" name="L2707" href="#L2707">2707</a> <strong class="jxr_keyword">public</strong> Double convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> Double.valueOf(value); }
<a class="jxr_linenumber" name="L2708" href="#L2708">2708</a> }
<a class="jxr_linenumber" name="L2709" href="#L2709">2709</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">FileConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;File&gt; {
<a class="jxr_linenumber" name="L2710" href="#L2710">2710</a> @Override
<a class="jxr_linenumber" name="L2711" href="#L2711">2711</a> <strong class="jxr_keyword">public</strong> File convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> File(value); }
<a class="jxr_linenumber" name="L2712" href="#L2712">2712</a> }
<a class="jxr_linenumber" name="L2713" href="#L2713">2713</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">URLConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;URL&gt; {
<a class="jxr_linenumber" name="L2714" href="#L2714">2714</a> @Override
<a class="jxr_linenumber" name="L2715" href="#L2715">2715</a> <strong class="jxr_keyword">public</strong> URL convert(<strong class="jxr_keyword">final</strong> String value) <strong class="jxr_keyword">throws</strong> MalformedURLException { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> URL(value); }
<a class="jxr_linenumber" name="L2716" href="#L2716">2716</a> }
<a class="jxr_linenumber" name="L2717" href="#L2717">2717</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">URIConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;URI&gt; {
<a class="jxr_linenumber" name="L2718" href="#L2718">2718</a> @Override
<a class="jxr_linenumber" name="L2719" href="#L2719">2719</a> <strong class="jxr_keyword">public</strong> URI convert(<strong class="jxr_keyword">final</strong> String value) <strong class="jxr_keyword">throws</strong> URISyntaxException { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> URI(value); }
<a class="jxr_linenumber" name="L2720" href="#L2720">2720</a> }
<a class="jxr_linenumber" name="L2721" href="#L2721">2721</a> <em class="jxr_javadoccomment">/** Converts text in {@code yyyy-mm-dd} format to a {@code java.util.Date}. ParameterException on failure. */</em>
<a class="jxr_linenumber" name="L2722" href="#L2722">2722</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ISO8601DateConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Date&gt; {
<a class="jxr_linenumber" name="L2723" href="#L2723">2723</a> @Override
<a class="jxr_linenumber" name="L2724" href="#L2724">2724</a> <strong class="jxr_keyword">public</strong> Date convert(<strong class="jxr_keyword">final</strong> String value) {
<a class="jxr_linenumber" name="L2725" href="#L2725">2725</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L2726" href="#L2726">2726</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> SimpleDateFormat(<span class="jxr_string">"yyyy-MM-dd"</span>).parse(value);
<a class="jxr_linenumber" name="L2727" href="#L2727">2727</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> ParseException e) {
<a class="jxr_linenumber" name="L2728" href="#L2728">2728</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TypeConversionException</a>(<span class="jxr_string">"'"</span> + value + <span class="jxr_string">"' is not a yyyy-MM-dd date"</span>);
<a class="jxr_linenumber" name="L2729" href="#L2729">2729</a> }
<a class="jxr_linenumber" name="L2730" href="#L2730">2730</a> }
<a class="jxr_linenumber" name="L2731" href="#L2731">2731</a> }
<a class="jxr_linenumber" name="L2732" href="#L2732">2732</a> <em class="jxr_javadoccomment">/** Converts text in any of the following formats to a {@code java.sql.Time}: {@code HH:mm}, {@code HH:mm:ss},</em>
<a class="jxr_linenumber" name="L2733" href="#L2733">2733</a> <em class="jxr_javadoccomment"> * {@code HH:mm:ss.SSS}, {@code HH:mm:ss,SSS}. Other formats result in a ParameterException. */</em>
<a class="jxr_linenumber" name="L2734" href="#L2734">2734</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ISO8601TimeConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Time&gt; {
<a class="jxr_linenumber" name="L2735" href="#L2735">2735</a> @Override
<a class="jxr_linenumber" name="L2736" href="#L2736">2736</a> <strong class="jxr_keyword">public</strong> Time convert(<strong class="jxr_keyword">final</strong> String value) {
<a class="jxr_linenumber" name="L2737" href="#L2737">2737</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L2738" href="#L2738">2738</a> <strong class="jxr_keyword">if</strong> (value.length() &lt;= 5) {
<a class="jxr_linenumber" name="L2739" href="#L2739">2739</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Time(<strong class="jxr_keyword">new</strong> SimpleDateFormat(<span class="jxr_string">"HH:mm"</span>).parse(value).getTime());
<a class="jxr_linenumber" name="L2740" href="#L2740">2740</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (value.length() &lt;= 8) {
<a class="jxr_linenumber" name="L2741" href="#L2741">2741</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Time(<strong class="jxr_keyword">new</strong> SimpleDateFormat(<span class="jxr_string">"HH:mm:ss"</span>).parse(value).getTime());
<a class="jxr_linenumber" name="L2742" href="#L2742">2742</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (value.length() &lt;= 12) {
<a class="jxr_linenumber" name="L2743" href="#L2743">2743</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L2744" href="#L2744">2744</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Time(<strong class="jxr_keyword">new</strong> SimpleDateFormat(<span class="jxr_string">"HH:mm:ss.SSS"</span>).parse(value).getTime());
<a class="jxr_linenumber" name="L2745" href="#L2745">2745</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> ParseException e2) {
<a class="jxr_linenumber" name="L2746" href="#L2746">2746</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Time(<strong class="jxr_keyword">new</strong> SimpleDateFormat(<span class="jxr_string">"HH:mm:ss,SSS"</span>).parse(value).getTime());
<a class="jxr_linenumber" name="L2747" href="#L2747">2747</a> }
<a class="jxr_linenumber" name="L2748" href="#L2748">2748</a> }
<a class="jxr_linenumber" name="L2749" href="#L2749">2749</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> ParseException ignored) {
<a class="jxr_linenumber" name="L2750" href="#L2750">2750</a> <em class="jxr_comment">// ignored because we throw a ParameterException below</em>
<a class="jxr_linenumber" name="L2751" href="#L2751">2751</a> }
<a class="jxr_linenumber" name="L2752" href="#L2752">2752</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TypeConversionException</a>(<span class="jxr_string">"'"</span> + value + <span class="jxr_string">"' is not a HH:mm[:ss[.SSS]] time"</span>);
<a class="jxr_linenumber" name="L2753" href="#L2753">2753</a> }
<a class="jxr_linenumber" name="L2754" href="#L2754">2754</a> }
<a class="jxr_linenumber" name="L2755" href="#L2755">2755</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">BigDecimalConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;BigDecimal&gt; {
<a class="jxr_linenumber" name="L2756" href="#L2756">2756</a> @Override
<a class="jxr_linenumber" name="L2757" href="#L2757">2757</a> <strong class="jxr_keyword">public</strong> BigDecimal convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> BigDecimal(value); }
<a class="jxr_linenumber" name="L2758" href="#L2758">2758</a> }
<a class="jxr_linenumber" name="L2759" href="#L2759">2759</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">BigIntegerConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;BigInteger&gt; {
<a class="jxr_linenumber" name="L2760" href="#L2760">2760</a> @Override
<a class="jxr_linenumber" name="L2761" href="#L2761">2761</a> <strong class="jxr_keyword">public</strong> BigInteger convert(<strong class="jxr_keyword">final</strong> String value) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> BigInteger(value); }
<a class="jxr_linenumber" name="L2762" href="#L2762">2762</a> }
<a class="jxr_linenumber" name="L2763" href="#L2763">2763</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CharsetConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Charset&gt; {
<a class="jxr_linenumber" name="L2764" href="#L2764">2764</a> @Override
<a class="jxr_linenumber" name="L2765" href="#L2765">2765</a> <strong class="jxr_keyword">public</strong> Charset convert(<strong class="jxr_keyword">final</strong> String s) { <strong class="jxr_keyword">return</strong> Charset.forName(s); }
<a class="jxr_linenumber" name="L2766" href="#L2766">2766</a> }
<a class="jxr_linenumber" name="L2767" href="#L2767">2767</a> <em class="jxr_javadoccomment">/** Converts text to a {@code InetAddress} by delegating to {@link InetAddress#getByName(String)}. */</em>
<a class="jxr_linenumber" name="L2768" href="#L2768">2768</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InetAddressConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;InetAddress&gt; {
<a class="jxr_linenumber" name="L2769" href="#L2769">2769</a> @Override
<a class="jxr_linenumber" name="L2770" href="#L2770">2770</a> <strong class="jxr_keyword">public</strong> InetAddress convert(<strong class="jxr_keyword">final</strong> String s) <strong class="jxr_keyword">throws</strong> Exception { <strong class="jxr_keyword">return</strong> InetAddress.getByName(s); }
<a class="jxr_linenumber" name="L2771" href="#L2771">2771</a> }
<a class="jxr_linenumber" name="L2772" href="#L2772">2772</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PatternConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;Pattern&gt; {
<a class="jxr_linenumber" name="L2773" href="#L2773">2773</a> @Override
<a class="jxr_linenumber" name="L2774" href="#L2774">2774</a> <strong class="jxr_keyword">public</strong> Pattern convert(<strong class="jxr_keyword">final</strong> String s) { <strong class="jxr_keyword">return</strong> Pattern.compile(s); }
<a class="jxr_linenumber" name="L2775" href="#L2775">2775</a> }
<a class="jxr_linenumber" name="L2776" href="#L2776">2776</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">UUIDConverter</a> <strong class="jxr_keyword">implements</strong> ITypeConverter&lt;UUID&gt; {
<a class="jxr_linenumber" name="L2777" href="#L2777">2777</a> @Override
<a class="jxr_linenumber" name="L2778" href="#L2778">2778</a> <strong class="jxr_keyword">public</strong> UUID convert(<strong class="jxr_keyword">final</strong> String s) <strong class="jxr_keyword">throws</strong> Exception { <strong class="jxr_keyword">return</strong> UUID.fromString(s); }
<a class="jxr_linenumber" name="L2779" href="#L2779">2779</a> }
<a class="jxr_linenumber" name="L2780" href="#L2780">2780</a> <strong class="jxr_keyword">private</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">BuiltIn</a>() {} <em class="jxr_comment">// private constructor: never instantiate</em>
<a class="jxr_linenumber" name="L2781" href="#L2781">2781</a> }
<a class="jxr_linenumber" name="L2782" href="#L2782">2782</a>
<a class="jxr_linenumber" name="L2783" href="#L2783">2783</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L2784" href="#L2784">2784</a> <em class="jxr_javadoccomment"> * A collection of methods and inner classes that provide fine-grained control over the contents and layout of</em>
<a class="jxr_linenumber" name="L2785" href="#L2785">2785</a> <em class="jxr_javadoccomment"> * the usage help message to display to end users when help is requested or invalid input values were specified.</em>
<a class="jxr_linenumber" name="L2786" href="#L2786">2786</a> <em class="jxr_javadoccomment"> * &lt;h3&gt;Layered API&lt;/h3&gt;</em>
<a class="jxr_linenumber" name="L2787" href="#L2787">2787</a> <em class="jxr_javadoccomment"> * &lt;p&gt;The {@link Command} annotation provides the easiest way to customize usage help messages. See</em>
<a class="jxr_linenumber" name="L2788" href="#L2788">2788</a> <em class="jxr_javadoccomment"> * the &lt;a href="https://remkop.github.io/picocli/index.html#_usage_help"&gt;Manual&lt;/a&gt; for details.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L2789" href="#L2789">2789</a> <em class="jxr_javadoccomment"> * &lt;p&gt;This Help class provides high-level functions to create sections of the usage help message and headings</em>
<a class="jxr_linenumber" name="L2790" href="#L2790">2790</a> <em class="jxr_javadoccomment"> * for these sections. Instead of calling the {@link CommandLine#usage(PrintStream, CommandLine.Help.ColorScheme)}</em>
<a class="jxr_linenumber" name="L2791" href="#L2791">2791</a> <em class="jxr_javadoccomment"> * method, application authors may want to create a custom usage help message by reorganizing sections in a</em>
<a class="jxr_linenumber" name="L2792" href="#L2792">2792</a> <em class="jxr_javadoccomment"> * different order and/or adding custom sections.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L2793" href="#L2793">2793</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Finally, the Help class contains inner classes and interfaces that can be used to create custom help messages.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L2794" href="#L2794">2794</a> <em class="jxr_javadoccomment"> * &lt;h4&gt;IOptionRenderer and IParameterRenderer&lt;/h4&gt;</em>
<a class="jxr_linenumber" name="L2795" href="#L2795">2795</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Renders a field annotated with {@link Option} or {@link Parameters} to an array of {@link Text} values.</em>
<a class="jxr_linenumber" name="L2796" href="#L2796">2796</a> <em class="jxr_javadoccomment"> * By default, these values are&lt;/p&gt;&lt;ul&gt;</em>
<a class="jxr_linenumber" name="L2797" href="#L2797">2797</a> <em class="jxr_javadoccomment"> * &lt;li&gt;mandatory marker character (if the option/parameter is {@link Option#required() required})&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L2798" href="#L2798">2798</a> <em class="jxr_javadoccomment"> * &lt;li&gt;short option name (empty for parameters)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L2799" href="#L2799">2799</a> <em class="jxr_javadoccomment"> * &lt;li&gt;comma or empty (empty for parameters)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L2800" href="#L2800">2800</a> <em class="jxr_javadoccomment"> * &lt;li&gt;long option names (the parameter {@link IParamLabelRenderer label} for parameters)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L2801" href="#L2801">2801</a> <em class="jxr_javadoccomment"> * &lt;li&gt;description&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L2802" href="#L2802">2802</a> <em class="jxr_javadoccomment"> * &lt;/ul&gt;</em>
<a class="jxr_linenumber" name="L2803" href="#L2803">2803</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Other components rely on this ordering.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L2804" href="#L2804">2804</a> <em class="jxr_javadoccomment"> * &lt;h4&gt;Layout&lt;/h4&gt;</em>
<a class="jxr_linenumber" name="L2805" href="#L2805">2805</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Delegates to the renderers to create {@link Text} values for the annotated fields, and uses a</em>
<a class="jxr_linenumber" name="L2806" href="#L2806">2806</a> <em class="jxr_javadoccomment"> * {@link TextTable} to display these values in tabular format. Layout is responsible for deciding which values</em>
<a class="jxr_linenumber" name="L2807" href="#L2807">2807</a> <em class="jxr_javadoccomment"> * to display where in the table. By default, Layout shows one option or parameter per table row.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L2808" href="#L2808">2808</a> <em class="jxr_javadoccomment"> * &lt;h4&gt;TextTable&lt;/h4&gt;</em>
<a class="jxr_linenumber" name="L2809" href="#L2809">2809</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Responsible for spacing out {@link Text} values according to the {@link Column} definitions the table was</em>
<a class="jxr_linenumber" name="L2810" href="#L2810">2810</a> <em class="jxr_javadoccomment"> * created with. Columns have a width, indentation, and an overflow policy that decides what to do if a value is</em>
<a class="jxr_linenumber" name="L2811" href="#L2811">2811</a> <em class="jxr_javadoccomment"> * longer than the column's width.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L2812" href="#L2812">2812</a> <em class="jxr_javadoccomment"> * &lt;h4&gt;Text&lt;/h4&gt;</em>
<a class="jxr_linenumber" name="L2813" href="#L2813">2813</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Encapsulates rich text with styles and colors in a way that other components like {@link TextTable} are</em>
<a class="jxr_linenumber" name="L2814" href="#L2814">2814</a> <em class="jxr_javadoccomment"> * unaware of the embedded ANSI escape codes.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L2815" href="#L2815">2815</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L2816" href="#L2816">2816</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a> {
<a class="jxr_linenumber" name="L2817" href="#L2817">2817</a> <em class="jxr_javadoccomment">/** Constant String holding the default program name: {@value} */</em>
<a class="jxr_linenumber" name="L2818" href="#L2818">2818</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> String DEFAULT_COMMAND_NAME = <span class="jxr_string">"&lt;main class&gt;"</span>;
<a class="jxr_linenumber" name="L2819" href="#L2819">2819</a>
<a class="jxr_linenumber" name="L2820" href="#L2820">2820</a> <em class="jxr_javadoccomment">/** Constant String holding the default string that separates options from option parameters: {@value} */</em>
<a class="jxr_linenumber" name="L2821" href="#L2821">2821</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> String DEFAULT_SEPARATOR = <span class="jxr_string">"="</span>;
<a class="jxr_linenumber" name="L2822" href="#L2822">2822</a>
<a class="jxr_linenumber" name="L2823" href="#L2823">2823</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> usageHelpWidth = 80;
<a class="jxr_linenumber" name="L2824" href="#L2824">2824</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> optionsColumnWidth = 2 + 2 + 1 + 24;
<a class="jxr_linenumber" name="L2825" href="#L2825">2825</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Object command;
<a class="jxr_linenumber" name="L2826" href="#L2826">2826</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Map&lt;String, Help&gt; commands = <strong class="jxr_keyword">new</strong> LinkedHashMap&lt;String, Help&gt;();
<a class="jxr_linenumber" name="L2827" href="#L2827">2827</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> colorScheme;
<a class="jxr_linenumber" name="L2828" href="#L2828">2828</a>
<a class="jxr_linenumber" name="L2829" href="#L2829">2829</a> <em class="jxr_javadoccomment">/** Immutable list of fields annotated with {@link Option}, in declaration order. */</em>
<a class="jxr_linenumber" name="L2830" href="#L2830">2830</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; optionFields;
<a class="jxr_linenumber" name="L2831" href="#L2831">2831</a>
<a class="jxr_linenumber" name="L2832" href="#L2832">2832</a> <em class="jxr_javadoccomment">/** Immutable list of fields annotated with {@link Parameters}, or an empty list if no such field exists. */</em>
<a class="jxr_linenumber" name="L2833" href="#L2833">2833</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; positionalParametersFields;
<a class="jxr_linenumber" name="L2834" href="#L2834">2834</a>
<a class="jxr_linenumber" name="L2835" href="#L2835">2835</a> <em class="jxr_javadoccomment">/** The String to use as the separator between options and option parameters. {@code "="} by default,</em>
<a class="jxr_linenumber" name="L2836" href="#L2836">2836</a> <em class="jxr_javadoccomment"> * initialized from {@link Command#separator()} if defined.</em>
<a class="jxr_linenumber" name="L2837" href="#L2837">2837</a> <em class="jxr_javadoccomment"> * @see #parameterLabelRenderer */</em>
<a class="jxr_linenumber" name="L2838" href="#L2838">2838</a> <strong class="jxr_keyword">public</strong> String separator;
<a class="jxr_linenumber" name="L2839" href="#L2839">2839</a>
<a class="jxr_linenumber" name="L2840" href="#L2840">2840</a> <em class="jxr_javadoccomment">/** The String to use as the program name in the synopsis line of the help message.</em>
<a class="jxr_linenumber" name="L2841" href="#L2841">2841</a> <em class="jxr_javadoccomment"> * {@link #DEFAULT_COMMAND_NAME} by default, initialized from {@link Command#name()} if defined. */</em>
<a class="jxr_linenumber" name="L2842" href="#L2842">2842</a> <strong class="jxr_keyword">public</strong> String commandName = DEFAULT_COMMAND_NAME;
<a class="jxr_linenumber" name="L2843" href="#L2843">2843</a>
<a class="jxr_linenumber" name="L2844" href="#L2844">2844</a> <em class="jxr_javadoccomment">/** Optional text lines to use as the description of the help message, displayed between the synopsis and the</em>
<a class="jxr_linenumber" name="L2845" href="#L2845">2845</a> <em class="jxr_javadoccomment"> * options list. Initialized from {@link Command#description()} if the {@code Command} annotation is present,</em>
<a class="jxr_linenumber" name="L2846" href="#L2846">2846</a> <em class="jxr_javadoccomment"> * otherwise this is an empty array and the help message has no description.</em>
<a class="jxr_linenumber" name="L2847" href="#L2847">2847</a> <em class="jxr_javadoccomment"> * Applications may programmatically set this field to create a custom help message. */</em>
<a class="jxr_linenumber" name="L2848" href="#L2848">2848</a> <strong class="jxr_keyword">public</strong> String[] description = {};
<a class="jxr_linenumber" name="L2849" href="#L2849">2849</a>
<a class="jxr_linenumber" name="L2850" href="#L2850">2850</a> <em class="jxr_javadoccomment">/** Optional custom synopsis lines to use instead of the auto-generated synopsis.</em>
<a class="jxr_linenumber" name="L2851" href="#L2851">2851</a> <em class="jxr_javadoccomment"> * Initialized from {@link Command#customSynopsis()} if the {@code Command} annotation is present,</em>
<a class="jxr_linenumber" name="L2852" href="#L2852">2852</a> <em class="jxr_javadoccomment"> * otherwise this is an empty array and the synopsis is generated.</em>
<a class="jxr_linenumber" name="L2853" href="#L2853">2853</a> <em class="jxr_javadoccomment"> * Applications may programmatically set this field to create a custom help message. */</em>
<a class="jxr_linenumber" name="L2854" href="#L2854">2854</a> <strong class="jxr_keyword">public</strong> String[] customSynopsis = {};
<a class="jxr_linenumber" name="L2855" href="#L2855">2855</a>
<a class="jxr_linenumber" name="L2856" href="#L2856">2856</a> <em class="jxr_javadoccomment">/** Optional header lines displayed at the top of the help message. For subcommands, the first header line is</em>
<a class="jxr_linenumber" name="L2857" href="#L2857">2857</a> <em class="jxr_javadoccomment"> * displayed in the list of commands. Values are initialized from {@link Command#header()}</em>
<a class="jxr_linenumber" name="L2858" href="#L2858">2858</a> <em class="jxr_javadoccomment"> * if the {@code Command} annotation is present, otherwise this is an empty array and the help message has no</em>
<a class="jxr_linenumber" name="L2859" href="#L2859">2859</a> <em class="jxr_javadoccomment"> * header. Applications may programmatically set this field to create a custom help message. */</em>
<a class="jxr_linenumber" name="L2860" href="#L2860">2860</a> <strong class="jxr_keyword">public</strong> String[] header = {};
<a class="jxr_linenumber" name="L2861" href="#L2861">2861</a>
<a class="jxr_linenumber" name="L2862" href="#L2862">2862</a> <em class="jxr_javadoccomment">/** Optional footer text lines displayed at the bottom of the help message. Initialized from</em>
<a class="jxr_linenumber" name="L2863" href="#L2863">2863</a> <em class="jxr_javadoccomment"> * {@link Command#footer()} if the {@code Command} annotation is present, otherwise this is an empty array and</em>
<a class="jxr_linenumber" name="L2864" href="#L2864">2864</a> <em class="jxr_javadoccomment"> * the help message has no footer.</em>
<a class="jxr_linenumber" name="L2865" href="#L2865">2865</a> <em class="jxr_javadoccomment"> * Applications may programmatically set this field to create a custom help message. */</em>
<a class="jxr_linenumber" name="L2866" href="#L2866">2866</a> <strong class="jxr_keyword">public</strong> String[] footer = {};
<a class="jxr_linenumber" name="L2867" href="#L2867">2867</a>
<a class="jxr_linenumber" name="L2868" href="#L2868">2868</a> <em class="jxr_javadoccomment">/** Option and positional parameter value label renderer used for the synopsis line(s) and the option list.</em>
<a class="jxr_linenumber" name="L2869" href="#L2869">2869</a> <em class="jxr_javadoccomment"> * By default initialized to the result of {@link #createDefaultParamLabelRenderer()}, which takes a snapshot</em>
<a class="jxr_linenumber" name="L2870" href="#L2870">2870</a> <em class="jxr_javadoccomment"> * of the {@link #separator} at construction time. If the separator is modified after Help construction, you</em>
<a class="jxr_linenumber" name="L2871" href="#L2871">2871</a> <em class="jxr_javadoccomment"> * may need to re-initialize this field by calling {@link #createDefaultParamLabelRenderer()} again. */</em>
<a class="jxr_linenumber" name="L2872" href="#L2872">2872</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> parameterLabelRenderer;
<a class="jxr_linenumber" name="L2873" href="#L2873">2873</a>
<a class="jxr_linenumber" name="L2874" href="#L2874">2874</a> <em class="jxr_javadoccomment">/** If {@code true}, the synopsis line(s) will show an abbreviated synopsis without detailed option names. */</em>
<a class="jxr_linenumber" name="L2875" href="#L2875">2875</a> <strong class="jxr_keyword">public</strong> Boolean abbreviateSynopsis;
<a class="jxr_linenumber" name="L2876" href="#L2876">2876</a>
<a class="jxr_linenumber" name="L2877" href="#L2877">2877</a> <em class="jxr_javadoccomment">/** If {@code true}, the options list is sorted alphabetically. */</em>
<a class="jxr_linenumber" name="L2878" href="#L2878">2878</a> <strong class="jxr_keyword">public</strong> Boolean sortOptions;
<a class="jxr_linenumber" name="L2879" href="#L2879">2879</a>
<a class="jxr_linenumber" name="L2880" href="#L2880">2880</a> <em class="jxr_javadoccomment">/** If {@code true}, the options list will show default values for all options except booleans. */</em>
<a class="jxr_linenumber" name="L2881" href="#L2881">2881</a> <strong class="jxr_keyword">public</strong> Boolean showDefaultValues;
<a class="jxr_linenumber" name="L2882" href="#L2882">2882</a>
<a class="jxr_linenumber" name="L2883" href="#L2883">2883</a> <em class="jxr_javadoccomment">/** Character used to prefix required options in the options list. */</em>
<a class="jxr_linenumber" name="L2884" href="#L2884">2884</a> <strong class="jxr_keyword">public</strong> Character requiredOptionMarker;
<a class="jxr_linenumber" name="L2885" href="#L2885">2885</a>
<a class="jxr_linenumber" name="L2886" href="#L2886">2886</a> <em class="jxr_javadoccomment">/** Optional heading preceding the header section. Initialized from {@link Command#headerHeading()}, or null. */</em>
<a class="jxr_linenumber" name="L2887" href="#L2887">2887</a> <strong class="jxr_keyword">public</strong> String headerHeading;
<a class="jxr_linenumber" name="L2888" href="#L2888">2888</a>
<a class="jxr_linenumber" name="L2889" href="#L2889">2889</a> <em class="jxr_javadoccomment">/** Optional heading preceding the synopsis. Initialized from {@link Command#synopsisHeading()}, {@code "Usage: "} by default. */</em>
<a class="jxr_linenumber" name="L2890" href="#L2890">2890</a> <strong class="jxr_keyword">public</strong> String synopsisHeading;
<a class="jxr_linenumber" name="L2891" href="#L2891">2891</a>
<a class="jxr_linenumber" name="L2892" href="#L2892">2892</a> <em class="jxr_javadoccomment">/** Optional heading preceding the description section. Initialized from {@link Command#descriptionHeading()}, or null. */</em>
<a class="jxr_linenumber" name="L2893" href="#L2893">2893</a> <strong class="jxr_keyword">public</strong> String descriptionHeading;
<a class="jxr_linenumber" name="L2894" href="#L2894">2894</a>
<a class="jxr_linenumber" name="L2895" href="#L2895">2895</a> <em class="jxr_javadoccomment">/** Optional heading preceding the parameter list. Initialized from {@link Command#parameterListHeading()}, or null. */</em>
<a class="jxr_linenumber" name="L2896" href="#L2896">2896</a> <strong class="jxr_keyword">public</strong> String parameterListHeading;
<a class="jxr_linenumber" name="L2897" href="#L2897">2897</a>
<a class="jxr_linenumber" name="L2898" href="#L2898">2898</a> <em class="jxr_javadoccomment">/** Optional heading preceding the options list. Initialized from {@link Command#optionListHeading()}, or null. */</em>
<a class="jxr_linenumber" name="L2899" href="#L2899">2899</a> <strong class="jxr_keyword">public</strong> String optionListHeading;
<a class="jxr_linenumber" name="L2900" href="#L2900">2900</a>
<a class="jxr_linenumber" name="L2901" href="#L2901">2901</a> <em class="jxr_javadoccomment">/** Optional heading preceding the subcommand list. Initialized from {@link Command#commandListHeading()}. {@code "Commands:%n"} by default. */</em>
<a class="jxr_linenumber" name="L2902" href="#L2902">2902</a> <strong class="jxr_keyword">public</strong> String commandListHeading;
<a class="jxr_linenumber" name="L2903" href="#L2903">2903</a>
<a class="jxr_linenumber" name="L2904" href="#L2904">2904</a> <em class="jxr_javadoccomment">/** Optional heading preceding the footer section. Initialized from {@link Command#footerHeading()}, or null. */</em>
<a class="jxr_linenumber" name="L2905" href="#L2905">2905</a> <strong class="jxr_keyword">public</strong> String footerHeading;
<a class="jxr_linenumber" name="L2906" href="#L2906">2906</a>
<a class="jxr_linenumber" name="L2907" href="#L2907">2907</a> <em class="jxr_javadoccomment">/** Constructs a new {@code Help} instance with a default color scheme, initialized from annotatations</em>
<a class="jxr_linenumber" name="L2908" href="#L2908">2908</a> <em class="jxr_javadoccomment"> * on the specified class and superclasses.</em>
<a class="jxr_linenumber" name="L2909" href="#L2909">2909</a> <em class="jxr_javadoccomment"> * @param command the annotated object to create usage help for */</em>
<a class="jxr_linenumber" name="L2910" href="#L2910">2910</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a>(<strong class="jxr_keyword">final</strong> Object command) {
<a class="jxr_linenumber" name="L2911" href="#L2911">2911</a> <strong class="jxr_keyword">this</strong>(command, Ansi.AUTO);
<a class="jxr_linenumber" name="L2912" href="#L2912">2912</a> }
<a class="jxr_linenumber" name="L2913" href="#L2913">2913</a>
<a class="jxr_linenumber" name="L2914" href="#L2914">2914</a> <em class="jxr_javadoccomment">/** Constructs a new {@code Help} instance with a default color scheme, initialized from annotatations</em>
<a class="jxr_linenumber" name="L2915" href="#L2915">2915</a> <em class="jxr_javadoccomment"> * on the specified class and superclasses.</em>
<a class="jxr_linenumber" name="L2916" href="#L2916">2916</a> <em class="jxr_javadoccomment"> * @param command the annotated object to create usage help for</em>
<a class="jxr_linenumber" name="L2917" href="#L2917">2917</a> <em class="jxr_javadoccomment"> * @param ansi whether to emit ANSI escape codes or not */</em>
<a class="jxr_linenumber" name="L2918" href="#L2918">2918</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a>(<strong class="jxr_keyword">final</strong> Object command, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi) {
<a class="jxr_linenumber" name="L2919" href="#L2919">2919</a> <strong class="jxr_keyword">this</strong>(command, defaultColorScheme(ansi));
<a class="jxr_linenumber" name="L2920" href="#L2920">2920</a> }
<a class="jxr_linenumber" name="L2921" href="#L2921">2921</a>
<a class="jxr_linenumber" name="L2922" href="#L2922">2922</a> <em class="jxr_javadoccomment">/** Constructs a new {@code Help} instance with the specified color scheme, initialized from annotatations</em>
<a class="jxr_linenumber" name="L2923" href="#L2923">2923</a> <em class="jxr_javadoccomment"> * on the specified class and superclasses.</em>
<a class="jxr_linenumber" name="L2924" href="#L2924">2924</a> <em class="jxr_javadoccomment"> * @param command the annotated object to create usage help for</em>
<a class="jxr_linenumber" name="L2925" href="#L2925">2925</a> <em class="jxr_javadoccomment"> * @param colorScheme the color scheme to use */</em>
<a class="jxr_linenumber" name="L2926" href="#L2926">2926</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a>(<strong class="jxr_keyword">final</strong> Object command, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> colorScheme) {
<a class="jxr_linenumber" name="L2927" href="#L2927">2927</a> <strong class="jxr_keyword">this</strong>.command = Assert.notNull(command, <span class="jxr_string">"command"</span>);
<a class="jxr_linenumber" name="L2928" href="#L2928">2928</a> <strong class="jxr_keyword">this</strong>.colorScheme = Assert.notNull(colorScheme, <span class="jxr_string">"colorScheme"</span>).applySystemProperties();
<a class="jxr_linenumber" name="L2929" href="#L2929">2929</a> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; options = <strong class="jxr_keyword">new</strong> ArrayList&lt;Field&gt;();
<a class="jxr_linenumber" name="L2930" href="#L2930">2930</a> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; operands = <strong class="jxr_keyword">new</strong> ArrayList&lt;Field&gt;();
<a class="jxr_linenumber" name="L2931" href="#L2931">2931</a> Class&lt;?&gt; cls = command.getClass();
<a class="jxr_linenumber" name="L2932" href="#L2932">2932</a> <strong class="jxr_keyword">while</strong> (cls != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L2933" href="#L2933">2933</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field field : cls.getDeclaredFields()) {
<a class="jxr_linenumber" name="L2934" href="#L2934">2934</a> field.setAccessible(<strong class="jxr_keyword">true</strong>);
<a class="jxr_linenumber" name="L2935" href="#L2935">2935</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L2936" href="#L2936">2936</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option = field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L2937" href="#L2937">2937</a> <strong class="jxr_keyword">if</strong> (!option.hidden()) { <em class="jxr_comment">// hidden options should not appear in usage help</em>
<a class="jxr_linenumber" name="L2938" href="#L2938">2938</a> <em class="jxr_comment">// TODO remember longest concatenated option string length (issue #45)</em>
<a class="jxr_linenumber" name="L2939" href="#L2939">2939</a> options.add(field);
<a class="jxr_linenumber" name="L2940" href="#L2940">2940</a> }
<a class="jxr_linenumber" name="L2941" href="#L2941">2941</a> }
<a class="jxr_linenumber" name="L2942" href="#L2942">2942</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L2943" href="#L2943">2943</a> operands.add(field);
<a class="jxr_linenumber" name="L2944" href="#L2944">2944</a> }
<a class="jxr_linenumber" name="L2945" href="#L2945">2945</a> }
<a class="jxr_linenumber" name="L2946" href="#L2946">2946</a> <em class="jxr_comment">// superclass values should not overwrite values if both class and superclass have a @Command annotation</em>
<a class="jxr_linenumber" name="L2947" href="#L2947">2947</a> <strong class="jxr_keyword">if</strong> (cls.isAnnotationPresent(Command.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L2948" href="#L2948">2948</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Command</a> cmd = cls.getAnnotation(Command.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L2949" href="#L2949">2949</a> <strong class="jxr_keyword">if</strong> (DEFAULT_COMMAND_NAME.equals(commandName)) {
<a class="jxr_linenumber" name="L2950" href="#L2950">2950</a> commandName = cmd.name();
<a class="jxr_linenumber" name="L2951" href="#L2951">2951</a> }
<a class="jxr_linenumber" name="L2952" href="#L2952">2952</a> separator = (separator == <strong class="jxr_keyword">null</strong>) ? cmd.separator() : separator;
<a class="jxr_linenumber" name="L2953" href="#L2953">2953</a> abbreviateSynopsis = (abbreviateSynopsis == <strong class="jxr_keyword">null</strong>) ? cmd.abbreviateSynopsis() : abbreviateSynopsis;
<a class="jxr_linenumber" name="L2954" href="#L2954">2954</a> sortOptions = (sortOptions == <strong class="jxr_keyword">null</strong>) ? cmd.sortOptions() : sortOptions;
<a class="jxr_linenumber" name="L2955" href="#L2955">2955</a> requiredOptionMarker = (requiredOptionMarker == <strong class="jxr_keyword">null</strong>) ? cmd.requiredOptionMarker() : requiredOptionMarker;
<a class="jxr_linenumber" name="L2956" href="#L2956">2956</a> showDefaultValues = (showDefaultValues == <strong class="jxr_keyword">null</strong>) ? cmd.showDefaultValues() : showDefaultValues;
<a class="jxr_linenumber" name="L2957" href="#L2957">2957</a> customSynopsis = empty(customSynopsis) ? cmd.customSynopsis() : customSynopsis;
<a class="jxr_linenumber" name="L2958" href="#L2958">2958</a> description = empty(description) ? cmd.description() : description;
<a class="jxr_linenumber" name="L2959" href="#L2959">2959</a> header = empty(header) ? cmd.header() : header;
<a class="jxr_linenumber" name="L2960" href="#L2960">2960</a> footer = empty(footer) ? cmd.footer() : footer;
<a class="jxr_linenumber" name="L2961" href="#L2961">2961</a> headerHeading = empty(headerHeading) ? cmd.headerHeading() : headerHeading;
<a class="jxr_linenumber" name="L2962" href="#L2962">2962</a> synopsisHeading = empty(synopsisHeading) || <span class="jxr_string">"Usage: "</span>.equals(synopsisHeading) ? cmd.synopsisHeading() : synopsisHeading;
<a class="jxr_linenumber" name="L2963" href="#L2963">2963</a> descriptionHeading = empty(descriptionHeading) ? cmd.descriptionHeading() : descriptionHeading;
<a class="jxr_linenumber" name="L2964" href="#L2964">2964</a> parameterListHeading = empty(parameterListHeading) ? cmd.parameterListHeading() : parameterListHeading;
<a class="jxr_linenumber" name="L2965" href="#L2965">2965</a> optionListHeading = empty(optionListHeading) ? cmd.optionListHeading() : optionListHeading;
<a class="jxr_linenumber" name="L2966" href="#L2966">2966</a> commandListHeading = empty(commandListHeading) || <span class="jxr_string">"Commands:%n"</span>.equals(commandListHeading) ? cmd.commandListHeading() : commandListHeading;
<a class="jxr_linenumber" name="L2967" href="#L2967">2967</a> footerHeading = empty(footerHeading) ? cmd.footerHeading() : footerHeading;
<a class="jxr_linenumber" name="L2968" href="#L2968">2968</a> }
<a class="jxr_linenumber" name="L2969" href="#L2969">2969</a> cls = cls.getSuperclass();
<a class="jxr_linenumber" name="L2970" href="#L2970">2970</a> }
<a class="jxr_linenumber" name="L2971" href="#L2971">2971</a> sortOptions = (sortOptions == <strong class="jxr_keyword">null</strong>) ? <strong class="jxr_keyword">true</strong> : sortOptions;
<a class="jxr_linenumber" name="L2972" href="#L2972">2972</a> abbreviateSynopsis = (abbreviateSynopsis == <strong class="jxr_keyword">null</strong>) ? false : abbreviateSynopsis;
<a class="jxr_linenumber" name="L2973" href="#L2973">2973</a> requiredOptionMarker = (requiredOptionMarker == <strong class="jxr_keyword">null</strong>) ? ' ' : requiredOptionMarker;
<a class="jxr_linenumber" name="L2974" href="#L2974">2974</a> showDefaultValues = (showDefaultValues == <strong class="jxr_keyword">null</strong>) ? false : showDefaultValues;
<a class="jxr_linenumber" name="L2975" href="#L2975">2975</a> synopsisHeading = (synopsisHeading == <strong class="jxr_keyword">null</strong>) ? <span class="jxr_string">"Usage: "</span> : synopsisHeading;
<a class="jxr_linenumber" name="L2976" href="#L2976">2976</a> commandListHeading = (commandListHeading == <strong class="jxr_keyword">null</strong>) ? <span class="jxr_string">"Commands:%n"</span> : commandListHeading;
<a class="jxr_linenumber" name="L2977" href="#L2977">2977</a> separator = (separator == <strong class="jxr_keyword">null</strong>) ? DEFAULT_SEPARATOR : separator;
<a class="jxr_linenumber" name="L2978" href="#L2978">2978</a> parameterLabelRenderer = createDefaultParamLabelRenderer(); <em class="jxr_comment">// uses help separator</em>
<a class="jxr_linenumber" name="L2979" href="#L2979">2979</a> Collections.sort(operands, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PositionalParametersSorter</a>());
<a class="jxr_linenumber" name="L2980" href="#L2980">2980</a> positionalParametersFields = Collections.unmodifiableList(operands);
<a class="jxr_linenumber" name="L2981" href="#L2981">2981</a> optionFields = Collections.unmodifiableList(options);
<a class="jxr_linenumber" name="L2982" href="#L2982">2982</a> }
<a class="jxr_linenumber" name="L2983" href="#L2983">2983</a>
<a class="jxr_linenumber" name="L2984" href="#L2984">2984</a> <em class="jxr_javadoccomment">/** Registers all specified subcommands with this Help.</em>
<a class="jxr_linenumber" name="L2985" href="#L2985">2985</a> <em class="jxr_javadoccomment"> * @param commands maps the command names to the associated CommandLine object</em>
<a class="jxr_linenumber" name="L2986" href="#L2986">2986</a> <em class="jxr_javadoccomment"> * @return this Help instance (for method chaining)</em>
<a class="jxr_linenumber" name="L2987" href="#L2987">2987</a> <em class="jxr_javadoccomment"> * @see CommandLine#getSubcommands()</em>
<a class="jxr_linenumber" name="L2988" href="#L2988">2988</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L2989" href="#L2989">2989</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a> addAllSubcommands(<strong class="jxr_keyword">final</strong> Map&lt;String, CommandLine&gt; commands) {
<a class="jxr_linenumber" name="L2990" href="#L2990">2990</a> <strong class="jxr_keyword">if</strong> (commands != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L2991" href="#L2991">2991</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Map.Entry&lt;String, CommandLine&gt; entry : commands.entrySet()) {
<a class="jxr_linenumber" name="L2992" href="#L2992">2992</a> addSubcommand(entry.getKey(), entry.getValue().getCommand());
<a class="jxr_linenumber" name="L2993" href="#L2993">2993</a> }
<a class="jxr_linenumber" name="L2994" href="#L2994">2994</a> }
<a class="jxr_linenumber" name="L2995" href="#L2995">2995</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L2996" href="#L2996">2996</a> }
<a class="jxr_linenumber" name="L2997" href="#L2997">2997</a>
<a class="jxr_linenumber" name="L2998" href="#L2998">2998</a> <em class="jxr_javadoccomment">/** Registers the specified subcommand with this Help.</em>
<a class="jxr_linenumber" name="L2999" href="#L2999">2999</a> <em class="jxr_javadoccomment"> * @param commandName the name of the subcommand to display in the usage message</em>
<a class="jxr_linenumber" name="L3000" href="#L3000">3000</a> <em class="jxr_javadoccomment"> * @param command the annotated object to get more information from</em>
<a class="jxr_linenumber" name="L3001" href="#L3001">3001</a> <em class="jxr_javadoccomment"> * @return this Help instance (for method chaining)</em>
<a class="jxr_linenumber" name="L3002" href="#L3002">3002</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3003" href="#L3003">3003</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a> addSubcommand(<strong class="jxr_keyword">final</strong> String commandName, <strong class="jxr_keyword">final</strong> Object command) {
<a class="jxr_linenumber" name="L3004" href="#L3004">3004</a> commands.put(commandName, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a>(command));
<a class="jxr_linenumber" name="L3005" href="#L3005">3005</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L3006" href="#L3006">3006</a> }
<a class="jxr_linenumber" name="L3007" href="#L3007">3007</a>
<a class="jxr_linenumber" name="L3008" href="#L3008">3008</a> <em class="jxr_javadoccomment">/** Returns a synopsis for the command without reserving space for the synopsis heading.</em>
<a class="jxr_linenumber" name="L3009" href="#L3009">3009</a> <em class="jxr_javadoccomment"> * @return a synopsis</em>
<a class="jxr_linenumber" name="L3010" href="#L3010">3010</a> <em class="jxr_javadoccomment"> * @see #abbreviatedSynopsis()</em>
<a class="jxr_linenumber" name="L3011" href="#L3011">3011</a> <em class="jxr_javadoccomment"> * @see #detailedSynopsis(Comparator, boolean)</em>
<a class="jxr_linenumber" name="L3012" href="#L3012">3012</a> <em class="jxr_javadoccomment"> * @deprecated use {@link #synopsis(int)} instead</em>
<a class="jxr_linenumber" name="L3013" href="#L3013">3013</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3014" href="#L3014">3014</a> @Deprecated
<a class="jxr_linenumber" name="L3015" href="#L3015">3015</a> <strong class="jxr_keyword">public</strong> String synopsis() { <strong class="jxr_keyword">return</strong> synopsis(0); }
<a class="jxr_linenumber" name="L3016" href="#L3016">3016</a>
<a class="jxr_linenumber" name="L3017" href="#L3017">3017</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3018" href="#L3018">3018</a> <em class="jxr_javadoccomment"> * Returns a synopsis for the command, reserving the specified space for the synopsis heading.</em>
<a class="jxr_linenumber" name="L3019" href="#L3019">3019</a> <em class="jxr_javadoccomment"> * @param synopsisHeadingLength the length of the synopsis heading that will be displayed on the same line</em>
<a class="jxr_linenumber" name="L3020" href="#L3020">3020</a> <em class="jxr_javadoccomment"> * @return a synopsis</em>
<a class="jxr_linenumber" name="L3021" href="#L3021">3021</a> <em class="jxr_javadoccomment"> * @see #abbreviatedSynopsis()</em>
<a class="jxr_linenumber" name="L3022" href="#L3022">3022</a> <em class="jxr_javadoccomment"> * @see #detailedSynopsis(Comparator, boolean)</em>
<a class="jxr_linenumber" name="L3023" href="#L3023">3023</a> <em class="jxr_javadoccomment"> * @see #synopsisHeading</em>
<a class="jxr_linenumber" name="L3024" href="#L3024">3024</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3025" href="#L3025">3025</a> <strong class="jxr_keyword">public</strong> String synopsis(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> synopsisHeadingLength) {
<a class="jxr_linenumber" name="L3026" href="#L3026">3026</a> <strong class="jxr_keyword">if</strong> (!empty(customSynopsis)) { <strong class="jxr_keyword">return</strong> customSynopsis(); }
<a class="jxr_linenumber" name="L3027" href="#L3027">3027</a> <strong class="jxr_keyword">return</strong> abbreviateSynopsis ? abbreviatedSynopsis()
<a class="jxr_linenumber" name="L3028" href="#L3028">3028</a> : detailedSynopsis(synopsisHeadingLength, createShortOptionArityAndNameComparator(), <strong class="jxr_keyword">true</strong>);
<a class="jxr_linenumber" name="L3029" href="#L3029">3029</a> }
<a class="jxr_linenumber" name="L3030" href="#L3030">3030</a>
<a class="jxr_linenumber" name="L3031" href="#L3031">3031</a> <em class="jxr_javadoccomment">/** Generates a generic synopsis like {@code &lt;command name&gt; [OPTIONS] [PARAM1 [PARAM2]...]}, omitting parts</em>
<a class="jxr_linenumber" name="L3032" href="#L3032">3032</a> <em class="jxr_javadoccomment"> * that don't apply to the command (e.g., does not show [OPTIONS] if the command has no options).</em>
<a class="jxr_linenumber" name="L3033" href="#L3033">3033</a> <em class="jxr_javadoccomment"> * @return a generic synopsis */</em>
<a class="jxr_linenumber" name="L3034" href="#L3034">3034</a> <strong class="jxr_keyword">public</strong> String abbreviatedSynopsis() {
<a class="jxr_linenumber" name="L3035" href="#L3035">3035</a> <strong class="jxr_keyword">final</strong> StringBuilder sb = <strong class="jxr_keyword">new</strong> StringBuilder();
<a class="jxr_linenumber" name="L3036" href="#L3036">3036</a> <strong class="jxr_keyword">if</strong> (!optionFields.isEmpty()) { <em class="jxr_comment">// only show if annotated object actually has options</em>
<a class="jxr_linenumber" name="L3037" href="#L3037">3037</a> sb.append(<span class="jxr_string">" [OPTIONS]"</span>);
<a class="jxr_linenumber" name="L3038" href="#L3038">3038</a> }
<a class="jxr_linenumber" name="L3039" href="#L3039">3039</a> <em class="jxr_comment">// sb.append(" [--] "); // implied</em>
<a class="jxr_linenumber" name="L3040" href="#L3040">3040</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field positionalParam : positionalParametersFields) {
<a class="jxr_linenumber" name="L3041" href="#L3041">3041</a> <strong class="jxr_keyword">if</strong> (!positionalParam.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).hidden()) {
<a class="jxr_linenumber" name="L3042" href="#L3042">3042</a> sb.append(' ').append(parameterLabelRenderer.renderParameterLabel(positionalParam, ansi(), colorScheme.parameterStyles));
<a class="jxr_linenumber" name="L3043" href="#L3043">3043</a> }
<a class="jxr_linenumber" name="L3044" href="#L3044">3044</a> }
<a class="jxr_linenumber" name="L3045" href="#L3045">3045</a> <strong class="jxr_keyword">return</strong> colorScheme.commandText(commandName).toString()
<a class="jxr_linenumber" name="L3046" href="#L3046">3046</a> + (sb.toString()) + System.getProperty(<span class="jxr_string">"line.separator"</span>);
<a class="jxr_linenumber" name="L3047" href="#L3047">3047</a> }
<a class="jxr_linenumber" name="L3048" href="#L3048">3048</a> <em class="jxr_javadoccomment">/** Generates a detailed synopsis message showing all options and parameters. Follows the unix convention of</em>
<a class="jxr_linenumber" name="L3049" href="#L3049">3049</a> <em class="jxr_javadoccomment"> * showing optional options and parameters in square brackets ({@code [ ]}).</em>
<a class="jxr_linenumber" name="L3050" href="#L3050">3050</a> <em class="jxr_javadoccomment"> * @param optionSort comparator to sort options or {@code null} if options should not be sorted</em>
<a class="jxr_linenumber" name="L3051" href="#L3051">3051</a> <em class="jxr_javadoccomment"> * @param clusterBooleanOptions {@code true} if boolean short options should be clustered into a single string</em>
<a class="jxr_linenumber" name="L3052" href="#L3052">3052</a> <em class="jxr_javadoccomment"> * @return a detailed synopsis</em>
<a class="jxr_linenumber" name="L3053" href="#L3053">3053</a> <em class="jxr_javadoccomment"> * @deprecated use {@link #detailedSynopsis(int, Comparator, boolean)} instead. */</em>
<a class="jxr_linenumber" name="L3054" href="#L3054">3054</a> @Deprecated
<a class="jxr_linenumber" name="L3055" href="#L3055">3055</a> <strong class="jxr_keyword">public</strong> String detailedSynopsis(<strong class="jxr_keyword">final</strong> Comparator&lt;Field&gt; optionSort, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> clusterBooleanOptions) {
<a class="jxr_linenumber" name="L3056" href="#L3056">3056</a> <strong class="jxr_keyword">return</strong> detailedSynopsis(0, optionSort, clusterBooleanOptions);
<a class="jxr_linenumber" name="L3057" href="#L3057">3057</a> }
<a class="jxr_linenumber" name="L3058" href="#L3058">3058</a>
<a class="jxr_linenumber" name="L3059" href="#L3059">3059</a> <em class="jxr_javadoccomment">/** Generates a detailed synopsis message showing all options and parameters. Follows the unix convention of</em>
<a class="jxr_linenumber" name="L3060" href="#L3060">3060</a> <em class="jxr_javadoccomment"> * showing optional options and parameters in square brackets ({@code [ ]}).</em>
<a class="jxr_linenumber" name="L3061" href="#L3061">3061</a> <em class="jxr_javadoccomment"> * @param synopsisHeadingLength the length of the synopsis heading that will be displayed on the same line</em>
<a class="jxr_linenumber" name="L3062" href="#L3062">3062</a> <em class="jxr_javadoccomment"> * @param optionSort comparator to sort options or {@code null} if options should not be sorted</em>
<a class="jxr_linenumber" name="L3063" href="#L3063">3063</a> <em class="jxr_javadoccomment"> * @param clusterBooleanOptions {@code true} if boolean short options should be clustered into a single string</em>
<a class="jxr_linenumber" name="L3064" href="#L3064">3064</a> <em class="jxr_javadoccomment"> * @return a detailed synopsis */</em>
<a class="jxr_linenumber" name="L3065" href="#L3065">3065</a> <strong class="jxr_keyword">public</strong> String detailedSynopsis(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> synopsisHeadingLength, <strong class="jxr_keyword">final</strong> Comparator&lt;Field&gt; optionSort, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> clusterBooleanOptions) {
<a class="jxr_linenumber" name="L3066" href="#L3066">3066</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> optionText = ansi().<strong class="jxr_keyword">new</strong> Text(0);
<a class="jxr_linenumber" name="L3067" href="#L3067">3067</a> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; fields = <strong class="jxr_keyword">new</strong> ArrayList&lt;Field&gt;(optionFields); <em class="jxr_comment">// iterate in declaration order</em>
<a class="jxr_linenumber" name="L3068" href="#L3068">3068</a> <strong class="jxr_keyword">if</strong> (optionSort != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L3069" href="#L3069">3069</a> Collections.sort(fields, optionSort);<em class="jxr_comment">// iterate in specified sort order</em>
<a class="jxr_linenumber" name="L3070" href="#L3070">3070</a> }
<a class="jxr_linenumber" name="L3071" href="#L3071">3071</a> <strong class="jxr_keyword">if</strong> (clusterBooleanOptions) { <em class="jxr_comment">// cluster all short boolean options into a single string</em>
<a class="jxr_linenumber" name="L3072" href="#L3072">3072</a> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; booleanOptions = <strong class="jxr_keyword">new</strong> ArrayList&lt;Field&gt;();
<a class="jxr_linenumber" name="L3073" href="#L3073">3073</a> <strong class="jxr_keyword">final</strong> StringBuilder clusteredRequired = <strong class="jxr_keyword">new</strong> StringBuilder(<span class="jxr_string">"-"</span>);
<a class="jxr_linenumber" name="L3074" href="#L3074">3074</a> <strong class="jxr_keyword">final</strong> StringBuilder clusteredOptional = <strong class="jxr_keyword">new</strong> StringBuilder(<span class="jxr_string">"-"</span>);
<a class="jxr_linenumber" name="L3075" href="#L3075">3075</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field field : fields) {
<a class="jxr_linenumber" name="L3076" href="#L3076">3076</a> <strong class="jxr_keyword">if</strong> (field.getType() == <strong class="jxr_keyword">boolean</strong>.<strong class="jxr_keyword">class</strong> || field.getType() == Boolean.<strong class="jxr_keyword">class</strong>) {
<a class="jxr_linenumber" name="L3077" href="#L3077">3077</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option = field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3078" href="#L3078">3078</a> <strong class="jxr_keyword">final</strong> String shortestName = ShortestFirst.sort(option.names())[0];
<a class="jxr_linenumber" name="L3079" href="#L3079">3079</a> <strong class="jxr_keyword">if</strong> (shortestName.length() == 2 &amp;&amp; shortestName.startsWith(<span class="jxr_string">"-"</span>)) {
<a class="jxr_linenumber" name="L3080" href="#L3080">3080</a> booleanOptions.add(field);
<a class="jxr_linenumber" name="L3081" href="#L3081">3081</a> <strong class="jxr_keyword">if</strong> (option.required()) {
<a class="jxr_linenumber" name="L3082" href="#L3082">3082</a> clusteredRequired.append(shortestName.substring(1));
<a class="jxr_linenumber" name="L3083" href="#L3083">3083</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L3084" href="#L3084">3084</a> clusteredOptional.append(shortestName.substring(1));
<a class="jxr_linenumber" name="L3085" href="#L3085">3085</a> }
<a class="jxr_linenumber" name="L3086" href="#L3086">3086</a> }
<a class="jxr_linenumber" name="L3087" href="#L3087">3087</a> }
<a class="jxr_linenumber" name="L3088" href="#L3088">3088</a> }
<a class="jxr_linenumber" name="L3089" href="#L3089">3089</a> fields.removeAll(booleanOptions);
<a class="jxr_linenumber" name="L3090" href="#L3090">3090</a> <strong class="jxr_keyword">if</strong> (clusteredRequired.length() &gt; 1) { <em class="jxr_comment">// initial length was 1</em>
<a class="jxr_linenumber" name="L3091" href="#L3091">3091</a> optionText = optionText.append(<span class="jxr_string">" "</span>).append(colorScheme.optionText(clusteredRequired.toString()));
<a class="jxr_linenumber" name="L3092" href="#L3092">3092</a> }
<a class="jxr_linenumber" name="L3093" href="#L3093">3093</a> <strong class="jxr_keyword">if</strong> (clusteredOptional.length() &gt; 1) { <em class="jxr_comment">// initial length was 1</em>
<a class="jxr_linenumber" name="L3094" href="#L3094">3094</a> optionText = optionText.append(<span class="jxr_string">" ["</span>).append(colorScheme.optionText(clusteredOptional.toString())).append(<span class="jxr_string">"]"</span>);
<a class="jxr_linenumber" name="L3095" href="#L3095">3095</a> }
<a class="jxr_linenumber" name="L3096" href="#L3096">3096</a> }
<a class="jxr_linenumber" name="L3097" href="#L3097">3097</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field field : fields) {
<a class="jxr_linenumber" name="L3098" href="#L3098">3098</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option = field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3099" href="#L3099">3099</a> <strong class="jxr_keyword">if</strong> (!option.hidden()) {
<a class="jxr_linenumber" name="L3100" href="#L3100">3100</a> <strong class="jxr_keyword">if</strong> (option.required()) {
<a class="jxr_linenumber" name="L3101" href="#L3101">3101</a> optionText = appendOptionSynopsis(optionText, field, ShortestFirst.sort(option.names())[0], <span class="jxr_string">" "</span>, <span class="jxr_string">""</span>);
<a class="jxr_linenumber" name="L3102" href="#L3102">3102</a> <strong class="jxr_keyword">if</strong> (isMultiValue(field)) {
<a class="jxr_linenumber" name="L3103" href="#L3103">3103</a> optionText = appendOptionSynopsis(optionText, field, ShortestFirst.sort(option.names())[0], <span class="jxr_string">" ["</span>, <span class="jxr_string">"]..."</span>);
<a class="jxr_linenumber" name="L3104" href="#L3104">3104</a> }
<a class="jxr_linenumber" name="L3105" href="#L3105">3105</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L3106" href="#L3106">3106</a> optionText = appendOptionSynopsis(optionText, field, ShortestFirst.sort(option.names())[0], <span class="jxr_string">" ["</span>, <span class="jxr_string">"]"</span>);
<a class="jxr_linenumber" name="L3107" href="#L3107">3107</a> <strong class="jxr_keyword">if</strong> (isMultiValue(field)) {
<a class="jxr_linenumber" name="L3108" href="#L3108">3108</a> optionText = optionText.append(<span class="jxr_string">"..."</span>);
<a class="jxr_linenumber" name="L3109" href="#L3109">3109</a> }
<a class="jxr_linenumber" name="L3110" href="#L3110">3110</a> }
<a class="jxr_linenumber" name="L3111" href="#L3111">3111</a> }
<a class="jxr_linenumber" name="L3112" href="#L3112">3112</a> }
<a class="jxr_linenumber" name="L3113" href="#L3113">3113</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field positionalParam : positionalParametersFields) {
<a class="jxr_linenumber" name="L3114" href="#L3114">3114</a> <strong class="jxr_keyword">if</strong> (!positionalParam.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).hidden()) {
<a class="jxr_linenumber" name="L3115" href="#L3115">3115</a> optionText = optionText.append(<span class="jxr_string">" "</span>);
<a class="jxr_linenumber" name="L3116" href="#L3116">3116</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> label = parameterLabelRenderer.renderParameterLabel(positionalParam, colorScheme.ansi(), colorScheme.parameterStyles);
<a class="jxr_linenumber" name="L3117" href="#L3117">3117</a> optionText = optionText.append(label);
<a class="jxr_linenumber" name="L3118" href="#L3118">3118</a> }
<a class="jxr_linenumber" name="L3119" href="#L3119">3119</a> }
<a class="jxr_linenumber" name="L3120" href="#L3120">3120</a> <em class="jxr_comment">// Fix for #142: first line of synopsis overshoots max. characters</em>
<a class="jxr_linenumber" name="L3121" href="#L3121">3121</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> firstColumnLength = commandName.length() + synopsisHeadingLength;
<a class="jxr_linenumber" name="L3122" href="#L3122">3122</a>
<a class="jxr_linenumber" name="L3123" href="#L3123">3123</a> <em class="jxr_comment">// synopsis heading ("Usage: ") may be on the same line, so adjust column width</em>
<a class="jxr_linenumber" name="L3124" href="#L3124">3124</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a> textTable = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a>(ansi(), firstColumnLength, usageHelpWidth - firstColumnLength);
<a class="jxr_linenumber" name="L3125" href="#L3125">3125</a> textTable.indentWrappedLines = 1; <em class="jxr_comment">// don't worry about first line: options (2nd column) always start with a space</em>
<a class="jxr_linenumber" name="L3126" href="#L3126">3126</a>
<a class="jxr_linenumber" name="L3127" href="#L3127">3127</a> <em class="jxr_comment">// right-adjust the command name by length of synopsis heading</em>
<a class="jxr_linenumber" name="L3128" href="#L3128">3128</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> PADDING = Ansi.OFF.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(stringOf('X', synopsisHeadingLength));
<a class="jxr_linenumber" name="L3129" href="#L3129">3129</a> textTable.addRowValues(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] {PADDING.append(colorScheme.commandText(commandName)), optionText});
<a class="jxr_linenumber" name="L3130" href="#L3130">3130</a> <strong class="jxr_keyword">return</strong> textTable.toString().substring(synopsisHeadingLength); <em class="jxr_comment">// cut off leading synopsis heading spaces</em>
<a class="jxr_linenumber" name="L3131" href="#L3131">3131</a> }
<a class="jxr_linenumber" name="L3132" href="#L3132">3132</a>
<a class="jxr_linenumber" name="L3133" href="#L3133">3133</a> <strong class="jxr_keyword">private</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> appendOptionSynopsis(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> optionText, <strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> String optionName, <strong class="jxr_keyword">final</strong> String prefix, <strong class="jxr_keyword">final</strong> String suffix) {
<a class="jxr_linenumber" name="L3134" href="#L3134">3134</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> optionParamText = parameterLabelRenderer.renderParameterLabel(field, colorScheme.ansi(), colorScheme.optionParamStyles);
<a class="jxr_linenumber" name="L3135" href="#L3135">3135</a> <strong class="jxr_keyword">return</strong> optionText.append(prefix)
<a class="jxr_linenumber" name="L3136" href="#L3136">3136</a> .append(colorScheme.optionText(optionName))
<a class="jxr_linenumber" name="L3137" href="#L3137">3137</a> .append(optionParamText)
<a class="jxr_linenumber" name="L3138" href="#L3138">3138</a> .append(suffix);
<a class="jxr_linenumber" name="L3139" href="#L3139">3139</a> }
<a class="jxr_linenumber" name="L3140" href="#L3140">3140</a>
<a class="jxr_linenumber" name="L3141" href="#L3141">3141</a> <em class="jxr_javadoccomment">/** Returns the number of characters the synopsis heading will take on the same line as the synopsis.</em>
<a class="jxr_linenumber" name="L3142" href="#L3142">3142</a> <em class="jxr_javadoccomment"> * @return the number of characters the synopsis heading will take on the same line as the synopsis.</em>
<a class="jxr_linenumber" name="L3143" href="#L3143">3143</a> <em class="jxr_javadoccomment"> * @see #detailedSynopsis(int, Comparator, boolean)</em>
<a class="jxr_linenumber" name="L3144" href="#L3144">3144</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3145" href="#L3145">3145</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> synopsisHeadingLength() {
<a class="jxr_linenumber" name="L3146" href="#L3146">3146</a> <strong class="jxr_keyword">final</strong> String[] lines = Ansi.OFF.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(synopsisHeading).toString().split(<span class="jxr_string">"&#92;&#92;r?&#92;&#92;n|&#92;&#92;r|%n"</span>, -1);
<a class="jxr_linenumber" name="L3147" href="#L3147">3147</a> <strong class="jxr_keyword">return</strong> lines[lines.length - 1].length();
<a class="jxr_linenumber" name="L3148" href="#L3148">3148</a> }
<a class="jxr_linenumber" name="L3149" href="#L3149">3149</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3150" href="#L3150">3150</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Returns a description of the {@linkplain Option options} supported by the application.</em>
<a class="jxr_linenumber" name="L3151" href="#L3151">3151</a> <em class="jxr_javadoccomment"> * This implementation {@linkplain #createShortOptionNameComparator() sorts options alphabetically}, and shows</em>
<a class="jxr_linenumber" name="L3152" href="#L3152">3152</a> <em class="jxr_javadoccomment"> * only the {@linkplain Option#hidden() non-hidden} options in a {@linkplain TextTable tabular format}</em>
<a class="jxr_linenumber" name="L3153" href="#L3153">3153</a> <em class="jxr_javadoccomment"> * using the {@linkplain #createDefaultOptionRenderer() default renderer} and {@linkplain Layout default layout}.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3154" href="#L3154">3154</a> <em class="jxr_javadoccomment"> * @return the fully formatted option list</em>
<a class="jxr_linenumber" name="L3155" href="#L3155">3155</a> <em class="jxr_javadoccomment"> * @see #optionList(Layout, Comparator, IParamLabelRenderer)</em>
<a class="jxr_linenumber" name="L3156" href="#L3156">3156</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3157" href="#L3157">3157</a> <strong class="jxr_keyword">public</strong> String optionList() {
<a class="jxr_linenumber" name="L3158" href="#L3158">3158</a> <strong class="jxr_keyword">final</strong> Comparator&lt;Field&gt; sortOrder = sortOptions == <strong class="jxr_keyword">null</strong> || sortOptions.booleanValue()
<a class="jxr_linenumber" name="L3159" href="#L3159">3159</a> ? createShortOptionNameComparator()
<a class="jxr_linenumber" name="L3160" href="#L3160">3160</a> : <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L3161" href="#L3161">3161</a> <strong class="jxr_keyword">return</strong> optionList(createDefaultLayout(), sortOrder, parameterLabelRenderer);
<a class="jxr_linenumber" name="L3162" href="#L3162">3162</a> }
<a class="jxr_linenumber" name="L3163" href="#L3163">3163</a>
<a class="jxr_linenumber" name="L3164" href="#L3164">3164</a> <em class="jxr_javadoccomment">/** Sorts all {@code Options} with the specified {@code comparator} (if the comparator is non-{@code null}),</em>
<a class="jxr_linenumber" name="L3165" href="#L3165">3165</a> <em class="jxr_javadoccomment"> * then {@linkplain Layout#addOption(Field, CommandLine.Help.IParamLabelRenderer) adds} all non-hidden options to the</em>
<a class="jxr_linenumber" name="L3166" href="#L3166">3166</a> <em class="jxr_javadoccomment"> * specified TextTable and returns the result of TextTable.toString().</em>
<a class="jxr_linenumber" name="L3167" href="#L3167">3167</a> <em class="jxr_javadoccomment"> * @param layout responsible for rendering the option list</em>
<a class="jxr_linenumber" name="L3168" href="#L3168">3168</a> <em class="jxr_javadoccomment"> * @param optionSort determines in what order {@code Options} should be listed. Declared order if {@code null}</em>
<a class="jxr_linenumber" name="L3169" href="#L3169">3169</a> <em class="jxr_javadoccomment"> * @param valueLabelRenderer used for options with a parameter</em>
<a class="jxr_linenumber" name="L3170" href="#L3170">3170</a> <em class="jxr_javadoccomment"> * @return the fully formatted option list</em>
<a class="jxr_linenumber" name="L3171" href="#L3171">3171</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3172" href="#L3172">3172</a> <strong class="jxr_keyword">public</strong> String optionList(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Layout</a> layout, <strong class="jxr_keyword">final</strong> Comparator&lt;Field&gt; optionSort, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> valueLabelRenderer) {
<a class="jxr_linenumber" name="L3173" href="#L3173">3173</a> <strong class="jxr_keyword">final</strong> List&lt;Field&gt; fields = <strong class="jxr_keyword">new</strong> ArrayList&lt;Field&gt;(optionFields); <em class="jxr_comment">// options are stored in order of declaration</em>
<a class="jxr_linenumber" name="L3174" href="#L3174">3174</a> <strong class="jxr_keyword">if</strong> (optionSort != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L3175" href="#L3175">3175</a> Collections.sort(fields, optionSort); <em class="jxr_comment">// default: sort options ABC</em>
<a class="jxr_linenumber" name="L3176" href="#L3176">3176</a> }
<a class="jxr_linenumber" name="L3177" href="#L3177">3177</a> layout.addOptions(fields, valueLabelRenderer);
<a class="jxr_linenumber" name="L3178" href="#L3178">3178</a> <strong class="jxr_keyword">return</strong> layout.toString();
<a class="jxr_linenumber" name="L3179" href="#L3179">3179</a> }
<a class="jxr_linenumber" name="L3180" href="#L3180">3180</a>
<a class="jxr_linenumber" name="L3181" href="#L3181">3181</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3182" href="#L3182">3182</a> <em class="jxr_javadoccomment"> * Returns the section of the usage help message that lists the parameters with their descriptions.</em>
<a class="jxr_linenumber" name="L3183" href="#L3183">3183</a> <em class="jxr_javadoccomment"> * @return the section of the usage help message that lists the parameters</em>
<a class="jxr_linenumber" name="L3184" href="#L3184">3184</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3185" href="#L3185">3185</a> <strong class="jxr_keyword">public</strong> String parameterList() {
<a class="jxr_linenumber" name="L3186" href="#L3186">3186</a> <strong class="jxr_keyword">return</strong> parameterList(createDefaultLayout(), parameterLabelRenderer);
<a class="jxr_linenumber" name="L3187" href="#L3187">3187</a> }
<a class="jxr_linenumber" name="L3188" href="#L3188">3188</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3189" href="#L3189">3189</a> <em class="jxr_javadoccomment"> * Returns the section of the usage help message that lists the parameters with their descriptions.</em>
<a class="jxr_linenumber" name="L3190" href="#L3190">3190</a> <em class="jxr_javadoccomment"> * @param layout the layout to use</em>
<a class="jxr_linenumber" name="L3191" href="#L3191">3191</a> <em class="jxr_javadoccomment"> * @param paramLabelRenderer for rendering parameter names</em>
<a class="jxr_linenumber" name="L3192" href="#L3192">3192</a> <em class="jxr_javadoccomment"> * @return the section of the usage help message that lists the parameters</em>
<a class="jxr_linenumber" name="L3193" href="#L3193">3193</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3194" href="#L3194">3194</a> <strong class="jxr_keyword">public</strong> String parameterList(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Layout</a> layout, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> paramLabelRenderer) {
<a class="jxr_linenumber" name="L3195" href="#L3195">3195</a> layout.addPositionalParameters(positionalParametersFields, paramLabelRenderer);
<a class="jxr_linenumber" name="L3196" href="#L3196">3196</a> <strong class="jxr_keyword">return</strong> layout.toString();
<a class="jxr_linenumber" name="L3197" href="#L3197">3197</a> }
<a class="jxr_linenumber" name="L3198" href="#L3198">3198</a>
<a class="jxr_linenumber" name="L3199" href="#L3199">3199</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String heading(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi, <strong class="jxr_keyword">final</strong> String values, <strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3200" href="#L3200">3200</a> <strong class="jxr_keyword">final</strong> StringBuilder sb = join(ansi, <strong class="jxr_keyword">new</strong> String[] {values}, <strong class="jxr_keyword">new</strong> StringBuilder(), params);
<a class="jxr_linenumber" name="L3201" href="#L3201">3201</a> String result = sb.toString();
<a class="jxr_linenumber" name="L3202" href="#L3202">3202</a> result = result.endsWith(System.getProperty(<span class="jxr_string">"line.separator"</span>))
<a class="jxr_linenumber" name="L3203" href="#L3203">3203</a> ? result.substring(0, result.length() - System.getProperty(<span class="jxr_string">"line.separator"</span>).length()) : result;
<a class="jxr_linenumber" name="L3204" href="#L3204">3204</a> <strong class="jxr_keyword">return</strong> result + <strong class="jxr_keyword">new</strong> String(spaces(countTrailingSpaces(values)));
<a class="jxr_linenumber" name="L3205" href="#L3205">3205</a> }
<a class="jxr_linenumber" name="L3206" href="#L3206">3206</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">char</strong>[] spaces(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length) { <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">char</strong>[] result = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">char</strong>[length]; Arrays.fill(result, ' '); <strong class="jxr_keyword">return</strong> result; }
<a class="jxr_linenumber" name="L3207" href="#L3207">3207</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> countTrailingSpaces(<strong class="jxr_keyword">final</strong> String str) {
<a class="jxr_linenumber" name="L3208" href="#L3208">3208</a> <strong class="jxr_keyword">if</strong> (str == <strong class="jxr_keyword">null</strong>) {<strong class="jxr_keyword">return</strong> 0;}
<a class="jxr_linenumber" name="L3209" href="#L3209">3209</a> <strong class="jxr_keyword">int</strong> trailingSpaces = 0;
<a class="jxr_linenumber" name="L3210" href="#L3210">3210</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = str.length() - 1; i &gt;= 0 &amp;&amp; str.charAt(i) == ' '; i--) { trailingSpaces++; }
<a class="jxr_linenumber" name="L3211" href="#L3211">3211</a> <strong class="jxr_keyword">return</strong> trailingSpaces;
<a class="jxr_linenumber" name="L3212" href="#L3212">3212</a> }
<a class="jxr_linenumber" name="L3213" href="#L3213">3213</a>
<a class="jxr_linenumber" name="L3214" href="#L3214">3214</a> <em class="jxr_javadoccomment">/** Formats each of the specified values and appends it to the specified StringBuilder.</em>
<a class="jxr_linenumber" name="L3215" href="#L3215">3215</a> <em class="jxr_javadoccomment"> * @param ansi whether the result should contain ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L3216" href="#L3216">3216</a> <em class="jxr_javadoccomment"> * @param values the values to format and append to the StringBuilder</em>
<a class="jxr_linenumber" name="L3217" href="#L3217">3217</a> <em class="jxr_javadoccomment"> * @param sb the StringBuilder to collect the formatted strings</em>
<a class="jxr_linenumber" name="L3218" href="#L3218">3218</a> <em class="jxr_javadoccomment"> * @param params the parameters to pass to the format method when formatting each value</em>
<a class="jxr_linenumber" name="L3219" href="#L3219">3219</a> <em class="jxr_javadoccomment"> * @return the specified StringBuilder */</em>
<a class="jxr_linenumber" name="L3220" href="#L3220">3220</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> StringBuilder join(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi, <strong class="jxr_keyword">final</strong> String[] values, <strong class="jxr_keyword">final</strong> StringBuilder sb, <strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3221" href="#L3221">3221</a> <strong class="jxr_keyword">if</strong> (values != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L3222" href="#L3222">3222</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a> table = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a>(ansi, usageHelpWidth);
<a class="jxr_linenumber" name="L3223" href="#L3223">3223</a> table.indentWrappedLines = 0;
<a class="jxr_linenumber" name="L3224" href="#L3224">3224</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> String summaryLine : values) {
<a class="jxr_linenumber" name="L3225" href="#L3225">3225</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] lines = ansi.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(format(summaryLine, params)).splitLines();
<a class="jxr_linenumber" name="L3226" href="#L3226">3226</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Text line : lines) { table.addRowValues(line); }
<a class="jxr_linenumber" name="L3227" href="#L3227">3227</a> }
<a class="jxr_linenumber" name="L3228" href="#L3228">3228</a> table.toString(sb);
<a class="jxr_linenumber" name="L3229" href="#L3229">3229</a> }
<a class="jxr_linenumber" name="L3230" href="#L3230">3230</a> <strong class="jxr_keyword">return</strong> sb;
<a class="jxr_linenumber" name="L3231" href="#L3231">3231</a> }
<a class="jxr_linenumber" name="L3232" href="#L3232">3232</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String format(<strong class="jxr_keyword">final</strong> String formatString, <strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3233" href="#L3233">3233</a> <strong class="jxr_keyword">return</strong> formatString == <strong class="jxr_keyword">null</strong> ? <span class="jxr_string">""</span> : String.format(formatString, params);
<a class="jxr_linenumber" name="L3234" href="#L3234">3234</a> }
<a class="jxr_linenumber" name="L3235" href="#L3235">3235</a> <em class="jxr_javadoccomment">/** Returns command custom synopsis as a string. A custom synopsis can be zero or more lines, and can be</em>
<a class="jxr_linenumber" name="L3236" href="#L3236">3236</a> <em class="jxr_javadoccomment"> * specified declaratively with the {@link Command#customSynopsis()} annotation attribute or programmatically</em>
<a class="jxr_linenumber" name="L3237" href="#L3237">3237</a> <em class="jxr_javadoccomment"> * by setting the Help instance's {@link Help#customSynopsis} field.</em>
<a class="jxr_linenumber" name="L3238" href="#L3238">3238</a> <em class="jxr_javadoccomment"> * @param params Arguments referenced by the format specifiers in the synopsis strings</em>
<a class="jxr_linenumber" name="L3239" href="#L3239">3239</a> <em class="jxr_javadoccomment"> * @return the custom synopsis lines combined into a single String (which may be empty)</em>
<a class="jxr_linenumber" name="L3240" href="#L3240">3240</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3241" href="#L3241">3241</a> <strong class="jxr_keyword">public</strong> String customSynopsis(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3242" href="#L3242">3242</a> <strong class="jxr_keyword">return</strong> join(ansi(), customSynopsis, <strong class="jxr_keyword">new</strong> StringBuilder(), params).toString();
<a class="jxr_linenumber" name="L3243" href="#L3243">3243</a> }
<a class="jxr_linenumber" name="L3244" href="#L3244">3244</a> <em class="jxr_javadoccomment">/** Returns command description text as a string. Description text can be zero or more lines, and can be specified</em>
<a class="jxr_linenumber" name="L3245" href="#L3245">3245</a> <em class="jxr_javadoccomment"> * declaratively with the {@link Command#description()} annotation attribute or programmatically by</em>
<a class="jxr_linenumber" name="L3246" href="#L3246">3246</a> <em class="jxr_javadoccomment"> * setting the Help instance's {@link Help#description} field.</em>
<a class="jxr_linenumber" name="L3247" href="#L3247">3247</a> <em class="jxr_javadoccomment"> * @param params Arguments referenced by the format specifiers in the description strings</em>
<a class="jxr_linenumber" name="L3248" href="#L3248">3248</a> <em class="jxr_javadoccomment"> * @return the description lines combined into a single String (which may be empty)</em>
<a class="jxr_linenumber" name="L3249" href="#L3249">3249</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3250" href="#L3250">3250</a> <strong class="jxr_keyword">public</strong> String description(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3251" href="#L3251">3251</a> <strong class="jxr_keyword">return</strong> join(ansi(), description, <strong class="jxr_keyword">new</strong> StringBuilder(), params).toString();
<a class="jxr_linenumber" name="L3252" href="#L3252">3252</a> }
<a class="jxr_linenumber" name="L3253" href="#L3253">3253</a> <em class="jxr_javadoccomment">/** Returns the command header text as a string. Header text can be zero or more lines, and can be specified</em>
<a class="jxr_linenumber" name="L3254" href="#L3254">3254</a> <em class="jxr_javadoccomment"> * declaratively with the {@link Command#header()} annotation attribute or programmatically by</em>
<a class="jxr_linenumber" name="L3255" href="#L3255">3255</a> <em class="jxr_javadoccomment"> * setting the Help instance's {@link Help#header} field.</em>
<a class="jxr_linenumber" name="L3256" href="#L3256">3256</a> <em class="jxr_javadoccomment"> * @param params Arguments referenced by the format specifiers in the header strings</em>
<a class="jxr_linenumber" name="L3257" href="#L3257">3257</a> <em class="jxr_javadoccomment"> * @return the header lines combined into a single String (which may be empty)</em>
<a class="jxr_linenumber" name="L3258" href="#L3258">3258</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3259" href="#L3259">3259</a> <strong class="jxr_keyword">public</strong> String header(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3260" href="#L3260">3260</a> <strong class="jxr_keyword">return</strong> join(ansi(), header, <strong class="jxr_keyword">new</strong> StringBuilder(), params).toString();
<a class="jxr_linenumber" name="L3261" href="#L3261">3261</a> }
<a class="jxr_linenumber" name="L3262" href="#L3262">3262</a> <em class="jxr_javadoccomment">/** Returns command footer text as a string. Footer text can be zero or more lines, and can be specified</em>
<a class="jxr_linenumber" name="L3263" href="#L3263">3263</a> <em class="jxr_javadoccomment"> * declaratively with the {@link Command#footer()} annotation attribute or programmatically by</em>
<a class="jxr_linenumber" name="L3264" href="#L3264">3264</a> <em class="jxr_javadoccomment"> * setting the Help instance's {@link Help#footer} field.</em>
<a class="jxr_linenumber" name="L3265" href="#L3265">3265</a> <em class="jxr_javadoccomment"> * @param params Arguments referenced by the format specifiers in the footer strings</em>
<a class="jxr_linenumber" name="L3266" href="#L3266">3266</a> <em class="jxr_javadoccomment"> * @return the footer lines combined into a single String (which may be empty)</em>
<a class="jxr_linenumber" name="L3267" href="#L3267">3267</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3268" href="#L3268">3268</a> <strong class="jxr_keyword">public</strong> String footer(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3269" href="#L3269">3269</a> <strong class="jxr_keyword">return</strong> join(ansi(), footer, <strong class="jxr_keyword">new</strong> StringBuilder(), params).toString();
<a class="jxr_linenumber" name="L3270" href="#L3270">3270</a> }
<a class="jxr_linenumber" name="L3271" href="#L3271">3271</a>
<a class="jxr_linenumber" name="L3272" href="#L3272">3272</a> <em class="jxr_javadoccomment">/** Returns the text displayed before the header text; the result of {@code String.format(headerHeading, params)}.</em>
<a class="jxr_linenumber" name="L3273" href="#L3273">3273</a> <em class="jxr_javadoccomment"> * @param params the parameters to use to format the header heading</em>
<a class="jxr_linenumber" name="L3274" href="#L3274">3274</a> <em class="jxr_javadoccomment"> * @return the formatted header heading */</em>
<a class="jxr_linenumber" name="L3275" href="#L3275">3275</a> <strong class="jxr_keyword">public</strong> String headerHeading(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3276" href="#L3276">3276</a> <strong class="jxr_keyword">return</strong> heading(ansi(), headerHeading, params);
<a class="jxr_linenumber" name="L3277" href="#L3277">3277</a> }
<a class="jxr_linenumber" name="L3278" href="#L3278">3278</a>
<a class="jxr_linenumber" name="L3279" href="#L3279">3279</a> <em class="jxr_javadoccomment">/** Returns the text displayed before the synopsis text; the result of {@code String.format(synopsisHeading, params)}.</em>
<a class="jxr_linenumber" name="L3280" href="#L3280">3280</a> <em class="jxr_javadoccomment"> * @param params the parameters to use to format the synopsis heading</em>
<a class="jxr_linenumber" name="L3281" href="#L3281">3281</a> <em class="jxr_javadoccomment"> * @return the formatted synopsis heading */</em>
<a class="jxr_linenumber" name="L3282" href="#L3282">3282</a> <strong class="jxr_keyword">public</strong> String synopsisHeading(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3283" href="#L3283">3283</a> <strong class="jxr_keyword">return</strong> heading(ansi(), synopsisHeading, params);
<a class="jxr_linenumber" name="L3284" href="#L3284">3284</a> }
<a class="jxr_linenumber" name="L3285" href="#L3285">3285</a>
<a class="jxr_linenumber" name="L3286" href="#L3286">3286</a> <em class="jxr_javadoccomment">/** Returns the text displayed before the description text; an empty string if there is no description,</em>
<a class="jxr_linenumber" name="L3287" href="#L3287">3287</a> <em class="jxr_javadoccomment"> * otherwise the result of {@code String.format(descriptionHeading, params)}.</em>
<a class="jxr_linenumber" name="L3288" href="#L3288">3288</a> <em class="jxr_javadoccomment"> * @param params the parameters to use to format the description heading</em>
<a class="jxr_linenumber" name="L3289" href="#L3289">3289</a> <em class="jxr_javadoccomment"> * @return the formatted description heading */</em>
<a class="jxr_linenumber" name="L3290" href="#L3290">3290</a> <strong class="jxr_keyword">public</strong> String descriptionHeading(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3291" href="#L3291">3291</a> <strong class="jxr_keyword">return</strong> empty(descriptionHeading) ? <span class="jxr_string">""</span> : heading(ansi(), descriptionHeading, params);
<a class="jxr_linenumber" name="L3292" href="#L3292">3292</a> }
<a class="jxr_linenumber" name="L3293" href="#L3293">3293</a>
<a class="jxr_linenumber" name="L3294" href="#L3294">3294</a> <em class="jxr_javadoccomment">/** Returns the text displayed before the positional parameter list; an empty string if there are no positional</em>
<a class="jxr_linenumber" name="L3295" href="#L3295">3295</a> <em class="jxr_javadoccomment"> * parameters, otherwise the result of {@code String.format(parameterListHeading, params)}.</em>
<a class="jxr_linenumber" name="L3296" href="#L3296">3296</a> <em class="jxr_javadoccomment"> * @param params the parameters to use to format the parameter list heading</em>
<a class="jxr_linenumber" name="L3297" href="#L3297">3297</a> <em class="jxr_javadoccomment"> * @return the formatted parameter list heading */</em>
<a class="jxr_linenumber" name="L3298" href="#L3298">3298</a> <strong class="jxr_keyword">public</strong> String parameterListHeading(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3299" href="#L3299">3299</a> <strong class="jxr_keyword">return</strong> positionalParametersFields.isEmpty() ? <span class="jxr_string">""</span> : heading(ansi(), parameterListHeading, params);
<a class="jxr_linenumber" name="L3300" href="#L3300">3300</a> }
<a class="jxr_linenumber" name="L3301" href="#L3301">3301</a>
<a class="jxr_linenumber" name="L3302" href="#L3302">3302</a> <em class="jxr_javadoccomment">/** Returns the text displayed before the option list; an empty string if there are no options,</em>
<a class="jxr_linenumber" name="L3303" href="#L3303">3303</a> <em class="jxr_javadoccomment"> * otherwise the result of {@code String.format(optionListHeading, params)}.</em>
<a class="jxr_linenumber" name="L3304" href="#L3304">3304</a> <em class="jxr_javadoccomment"> * @param params the parameters to use to format the option list heading</em>
<a class="jxr_linenumber" name="L3305" href="#L3305">3305</a> <em class="jxr_javadoccomment"> * @return the formatted option list heading */</em>
<a class="jxr_linenumber" name="L3306" href="#L3306">3306</a> <strong class="jxr_keyword">public</strong> String optionListHeading(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3307" href="#L3307">3307</a> <strong class="jxr_keyword">return</strong> optionFields.isEmpty() ? <span class="jxr_string">""</span> : heading(ansi(), optionListHeading, params);
<a class="jxr_linenumber" name="L3308" href="#L3308">3308</a> }
<a class="jxr_linenumber" name="L3309" href="#L3309">3309</a>
<a class="jxr_linenumber" name="L3310" href="#L3310">3310</a> <em class="jxr_javadoccomment">/** Returns the text displayed before the command list; an empty string if there are no commands,</em>
<a class="jxr_linenumber" name="L3311" href="#L3311">3311</a> <em class="jxr_javadoccomment"> * otherwise the result of {@code String.format(commandListHeading, params)}.</em>
<a class="jxr_linenumber" name="L3312" href="#L3312">3312</a> <em class="jxr_javadoccomment"> * @param params the parameters to use to format the command list heading</em>
<a class="jxr_linenumber" name="L3313" href="#L3313">3313</a> <em class="jxr_javadoccomment"> * @return the formatted command list heading */</em>
<a class="jxr_linenumber" name="L3314" href="#L3314">3314</a> <strong class="jxr_keyword">public</strong> String commandListHeading(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3315" href="#L3315">3315</a> <strong class="jxr_keyword">return</strong> commands.isEmpty() ? <span class="jxr_string">""</span> : heading(ansi(), commandListHeading, params);
<a class="jxr_linenumber" name="L3316" href="#L3316">3316</a> }
<a class="jxr_linenumber" name="L3317" href="#L3317">3317</a>
<a class="jxr_linenumber" name="L3318" href="#L3318">3318</a> <em class="jxr_javadoccomment">/** Returns the text displayed before the footer text; the result of {@code String.format(footerHeading, params)}.</em>
<a class="jxr_linenumber" name="L3319" href="#L3319">3319</a> <em class="jxr_javadoccomment"> * @param params the parameters to use to format the footer heading</em>
<a class="jxr_linenumber" name="L3320" href="#L3320">3320</a> <em class="jxr_javadoccomment"> * @return the formatted footer heading */</em>
<a class="jxr_linenumber" name="L3321" href="#L3321">3321</a> <strong class="jxr_keyword">public</strong> String footerHeading(<strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L3322" href="#L3322">3322</a> <strong class="jxr_keyword">return</strong> heading(ansi(), footerHeading, params);
<a class="jxr_linenumber" name="L3323" href="#L3323">3323</a> }
<a class="jxr_linenumber" name="L3324" href="#L3324">3324</a> <em class="jxr_javadoccomment">/** Returns a 2-column list with command names and the first line of their header or (if absent) description.</em>
<a class="jxr_linenumber" name="L3325" href="#L3325">3325</a> <em class="jxr_javadoccomment"> * @return a usage help section describing the added commands */</em>
<a class="jxr_linenumber" name="L3326" href="#L3326">3326</a> <strong class="jxr_keyword">public</strong> String commandList() {
<a class="jxr_linenumber" name="L3327" href="#L3327">3327</a> <strong class="jxr_keyword">if</strong> (commands.isEmpty()) { <strong class="jxr_keyword">return</strong> <span class="jxr_string">""</span>; }
<a class="jxr_linenumber" name="L3328" href="#L3328">3328</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> commandLength = maxLength(commands.keySet());
<a class="jxr_linenumber" name="L3329" href="#L3329">3329</a> <strong class="jxr_keyword">final</strong> Help.TextTable textTable = <strong class="jxr_keyword">new</strong> Help.TextTable(ansi(),
<a class="jxr_linenumber" name="L3330" href="#L3330">3330</a> <strong class="jxr_keyword">new</strong> Help.Column(commandLength + 2, 2, Help.Column.Overflow.SPAN),
<a class="jxr_linenumber" name="L3331" href="#L3331">3331</a> <strong class="jxr_keyword">new</strong> Help.Column(usageHelpWidth - (commandLength + 2), 2, Help.Column.Overflow.WRAP));
<a class="jxr_linenumber" name="L3332" href="#L3332">3332</a>
<a class="jxr_linenumber" name="L3333" href="#L3333">3333</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Map.Entry&lt;String, Help&gt; entry : commands.entrySet()) {
<a class="jxr_linenumber" name="L3334" href="#L3334">3334</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Help</a> command = entry.getValue();
<a class="jxr_linenumber" name="L3335" href="#L3335">3335</a> <strong class="jxr_keyword">final</strong> String header = command.header != <strong class="jxr_keyword">null</strong> &amp;&amp; command.header.length &gt; 0 ? command.header[0]
<a class="jxr_linenumber" name="L3336" href="#L3336">3336</a> : (command.description != <strong class="jxr_keyword">null</strong> &amp;&amp; command.description.length &gt; 0 ? command.description[0] : <span class="jxr_string">""</span>);
<a class="jxr_linenumber" name="L3337" href="#L3337">3337</a> textTable.addRowValues(colorScheme.commandText(entry.getKey()), ansi().<strong class="jxr_keyword">new</strong> Text(header));
<a class="jxr_linenumber" name="L3338" href="#L3338">3338</a> }
<a class="jxr_linenumber" name="L3339" href="#L3339">3339</a> <strong class="jxr_keyword">return</strong> textTable.toString();
<a class="jxr_linenumber" name="L3340" href="#L3340">3340</a> }
<a class="jxr_linenumber" name="L3341" href="#L3341">3341</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> maxLength(<strong class="jxr_keyword">final</strong> Collection&lt;String&gt; any) {
<a class="jxr_linenumber" name="L3342" href="#L3342">3342</a> <strong class="jxr_keyword">final</strong> List&lt;String&gt; strings = <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;(any);
<a class="jxr_linenumber" name="L3343" href="#L3343">3343</a> Collections.sort(strings, Collections.reverseOrder(Help.shortestFirst()));
<a class="jxr_linenumber" name="L3344" href="#L3344">3344</a> <strong class="jxr_keyword">return</strong> strings.get(0).length();
<a class="jxr_linenumber" name="L3345" href="#L3345">3345</a> }
<a class="jxr_linenumber" name="L3346" href="#L3346">3346</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String join(<strong class="jxr_keyword">final</strong> String[] names, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> offset, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length, <strong class="jxr_keyword">final</strong> String separator) {
<a class="jxr_linenumber" name="L3347" href="#L3347">3347</a> <strong class="jxr_keyword">if</strong> (names == <strong class="jxr_keyword">null</strong>) { <strong class="jxr_keyword">return</strong> <span class="jxr_string">""</span>; }
<a class="jxr_linenumber" name="L3348" href="#L3348">3348</a> <strong class="jxr_keyword">final</strong> StringBuilder result = <strong class="jxr_keyword">new</strong> StringBuilder();
<a class="jxr_linenumber" name="L3349" href="#L3349">3349</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = offset; i &lt; offset + length; i++) {
<a class="jxr_linenumber" name="L3350" href="#L3350">3350</a> result.append((i &gt; offset) ? separator : <span class="jxr_string">""</span>).append(names[i]);
<a class="jxr_linenumber" name="L3351" href="#L3351">3351</a> }
<a class="jxr_linenumber" name="L3352" href="#L3352">3352</a> <strong class="jxr_keyword">return</strong> result.toString();
<a class="jxr_linenumber" name="L3353" href="#L3353">3353</a> }
<a class="jxr_linenumber" name="L3354" href="#L3354">3354</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String stringOf(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">char</strong> chr, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length) {
<a class="jxr_linenumber" name="L3355" href="#L3355">3355</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">char</strong>[] buff = <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">char</strong>[length];
<a class="jxr_linenumber" name="L3356" href="#L3356">3356</a> Arrays.fill(buff, chr);
<a class="jxr_linenumber" name="L3357" href="#L3357">3357</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> String(buff);
<a class="jxr_linenumber" name="L3358" href="#L3358">3358</a> }
<a class="jxr_linenumber" name="L3359" href="#L3359">3359</a>
<a class="jxr_linenumber" name="L3360" href="#L3360">3360</a> <em class="jxr_javadoccomment">/** Returns a {@code Layout} instance configured with the user preferences captured in this Help instance.</em>
<a class="jxr_linenumber" name="L3361" href="#L3361">3361</a> <em class="jxr_javadoccomment"> * @return a Layout */</em>
<a class="jxr_linenumber" name="L3362" href="#L3362">3362</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Layout</a> createDefaultLayout() {
<a class="jxr_linenumber" name="L3363" href="#L3363">3363</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Layout</a>(colorScheme, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a>(colorScheme.ansi()), createDefaultOptionRenderer(), createDefaultParameterRenderer());
<a class="jxr_linenumber" name="L3364" href="#L3364">3364</a> }
<a class="jxr_linenumber" name="L3365" href="#L3365">3365</a> <em class="jxr_javadoccomment">/** Returns a new default OptionRenderer which converts {@link Option Options} to five columns of text to match</em>
<a class="jxr_linenumber" name="L3366" href="#L3366">3366</a> <em class="jxr_javadoccomment"> * the default {@linkplain TextTable TextTable} column layout. The first row of values looks like this:</em>
<a class="jxr_linenumber" name="L3367" href="#L3367">3367</a> <em class="jxr_javadoccomment"> * &lt;ol&gt;</em>
<a class="jxr_linenumber" name="L3368" href="#L3368">3368</a> <em class="jxr_javadoccomment"> * &lt;li&gt;the required option marker&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3369" href="#L3369">3369</a> <em class="jxr_javadoccomment"> * &lt;li&gt;2-character short option name (or empty string if no short option exists)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3370" href="#L3370">3370</a> <em class="jxr_javadoccomment"> * &lt;li&gt;comma separator (only if both short option and long option exist, empty string otherwise)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3371" href="#L3371">3371</a> <em class="jxr_javadoccomment"> * &lt;li&gt;comma-separated string with long option name(s)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3372" href="#L3372">3372</a> <em class="jxr_javadoccomment"> * &lt;li&gt;first element of the {@link Option#description()} array&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3373" href="#L3373">3373</a> <em class="jxr_javadoccomment"> * &lt;/ol&gt;</em>
<a class="jxr_linenumber" name="L3374" href="#L3374">3374</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Following this, there will be one row for each of the remaining elements of the {@link</em>
<a class="jxr_linenumber" name="L3375" href="#L3375">3375</a> <em class="jxr_javadoccomment"> * Option#description()} array, and these rows look like {@code {"", "", "", "", option.description()[i]}}.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3376" href="#L3376">3376</a> <em class="jxr_javadoccomment"> * &lt;p&gt;If configured, this option renderer adds an additional row to display the default field value.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3377" href="#L3377">3377</a> <em class="jxr_javadoccomment"> * @return a new default OptionRenderer</em>
<a class="jxr_linenumber" name="L3378" href="#L3378">3378</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3379" href="#L3379">3379</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IOptionRenderer</a> createDefaultOptionRenderer() {
<a class="jxr_linenumber" name="L3380" href="#L3380">3380</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultOptionRenderer</a> result = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultOptionRenderer</a>();
<a class="jxr_linenumber" name="L3381" href="#L3381">3381</a> result.requiredMarker = String.valueOf(requiredOptionMarker);
<a class="jxr_linenumber" name="L3382" href="#L3382">3382</a> <strong class="jxr_keyword">if</strong> (showDefaultValues != <strong class="jxr_keyword">null</strong> &amp;&amp; showDefaultValues.booleanValue()) {
<a class="jxr_linenumber" name="L3383" href="#L3383">3383</a> result.command = <strong class="jxr_keyword">this</strong>.command;
<a class="jxr_linenumber" name="L3384" href="#L3384">3384</a> }
<a class="jxr_linenumber" name="L3385" href="#L3385">3385</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L3386" href="#L3386">3386</a> }
<a class="jxr_linenumber" name="L3387" href="#L3387">3387</a> <em class="jxr_javadoccomment">/** Returns a new minimal OptionRenderer which converts {@link Option Options} to a single row with two columns</em>
<a class="jxr_linenumber" name="L3388" href="#L3388">3388</a> <em class="jxr_javadoccomment"> * of text: an option name and a description. If multiple names or descriptions exist, the first value is used.</em>
<a class="jxr_linenumber" name="L3389" href="#L3389">3389</a> <em class="jxr_javadoccomment"> * @return a new minimal OptionRenderer */</em>
<a class="jxr_linenumber" name="L3390" href="#L3390">3390</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IOptionRenderer</a> createMinimalOptionRenderer() {
<a class="jxr_linenumber" name="L3391" href="#L3391">3391</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MinimalOptionRenderer</a>();
<a class="jxr_linenumber" name="L3392" href="#L3392">3392</a> }
<a class="jxr_linenumber" name="L3393" href="#L3393">3393</a>
<a class="jxr_linenumber" name="L3394" href="#L3394">3394</a> <em class="jxr_javadoccomment">/** Returns a new default ParameterRenderer which converts {@link Parameters Parameters} to four columns of</em>
<a class="jxr_linenumber" name="L3395" href="#L3395">3395</a> <em class="jxr_javadoccomment"> * text to match the default {@linkplain TextTable TextTable} column layout. The first row of values looks like this:</em>
<a class="jxr_linenumber" name="L3396" href="#L3396">3396</a> <em class="jxr_javadoccomment"> * &lt;ol&gt;</em>
<a class="jxr_linenumber" name="L3397" href="#L3397">3397</a> <em class="jxr_javadoccomment"> * &lt;li&gt;empty string &lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3398" href="#L3398">3398</a> <em class="jxr_javadoccomment"> * &lt;li&gt;empty string &lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3399" href="#L3399">3399</a> <em class="jxr_javadoccomment"> * &lt;li&gt;parameter(s) label as rendered by the {@link IParamLabelRenderer}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3400" href="#L3400">3400</a> <em class="jxr_javadoccomment"> * &lt;li&gt;first element of the {@link Parameters#description()} array&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3401" href="#L3401">3401</a> <em class="jxr_javadoccomment"> * &lt;/ol&gt;</em>
<a class="jxr_linenumber" name="L3402" href="#L3402">3402</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Following this, there will be one row for each of the remaining elements of the {@link</em>
<a class="jxr_linenumber" name="L3403" href="#L3403">3403</a> <em class="jxr_javadoccomment"> * Parameters#description()} array, and these rows look like {@code {"", "", "", param.description()[i]}}.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3404" href="#L3404">3404</a> <em class="jxr_javadoccomment"> * &lt;p&gt;If configured, this parameter renderer adds an additional row to display the default field value.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3405" href="#L3405">3405</a> <em class="jxr_javadoccomment"> * @return a new default ParameterRenderer</em>
<a class="jxr_linenumber" name="L3406" href="#L3406">3406</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3407" href="#L3407">3407</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParameterRenderer</a> createDefaultParameterRenderer() {
<a class="jxr_linenumber" name="L3408" href="#L3408">3408</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultParameterRenderer</a> result = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultParameterRenderer</a>();
<a class="jxr_linenumber" name="L3409" href="#L3409">3409</a> result.requiredMarker = String.valueOf(requiredOptionMarker);
<a class="jxr_linenumber" name="L3410" href="#L3410">3410</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L3411" href="#L3411">3411</a> }
<a class="jxr_linenumber" name="L3412" href="#L3412">3412</a> <em class="jxr_javadoccomment">/** Returns a new minimal ParameterRenderer which converts {@link Parameters Parameters} to a single row with</em>
<a class="jxr_linenumber" name="L3413" href="#L3413">3413</a> <em class="jxr_javadoccomment"> * two columns of text: an option name and a description. If multiple descriptions exist, the first value is used.</em>
<a class="jxr_linenumber" name="L3414" href="#L3414">3414</a> <em class="jxr_javadoccomment"> * @return a new minimal ParameterRenderer */</em>
<a class="jxr_linenumber" name="L3415" href="#L3415">3415</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParameterRenderer</a> createMinimalParameterRenderer() {
<a class="jxr_linenumber" name="L3416" href="#L3416">3416</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MinimalParameterRenderer</a>();
<a class="jxr_linenumber" name="L3417" href="#L3417">3417</a> }
<a class="jxr_linenumber" name="L3418" href="#L3418">3418</a>
<a class="jxr_linenumber" name="L3419" href="#L3419">3419</a> <em class="jxr_javadoccomment">/** Returns a value renderer that returns the {@code paramLabel} if defined or the field name otherwise.</em>
<a class="jxr_linenumber" name="L3420" href="#L3420">3420</a> <em class="jxr_javadoccomment"> * @return a new minimal ParamLabelRenderer */</em>
<a class="jxr_linenumber" name="L3421" href="#L3421">3421</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> createMinimalParamLabelRenderer() {
<a class="jxr_linenumber" name="L3422" href="#L3422">3422</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a>() {
<a class="jxr_linenumber" name="L3423" href="#L3423">3423</a> @Override
<a class="jxr_linenumber" name="L3424" href="#L3424">3424</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> renderParameterLabel(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi, <strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; styles) {
<a class="jxr_linenumber" name="L3425" href="#L3425">3425</a> <strong class="jxr_keyword">final</strong> String text = DefaultParamLabelRenderer.renderParameterName(field);
<a class="jxr_linenumber" name="L3426" href="#L3426">3426</a> <strong class="jxr_keyword">return</strong> ansi.apply(text, styles);
<a class="jxr_linenumber" name="L3427" href="#L3427">3427</a> }
<a class="jxr_linenumber" name="L3428" href="#L3428">3428</a> @Override
<a class="jxr_linenumber" name="L3429" href="#L3429">3429</a> <strong class="jxr_keyword">public</strong> String separator() { <strong class="jxr_keyword">return</strong> <span class="jxr_string">""</span>; }
<a class="jxr_linenumber" name="L3430" href="#L3430">3430</a> };
<a class="jxr_linenumber" name="L3431" href="#L3431">3431</a> }
<a class="jxr_linenumber" name="L3432" href="#L3432">3432</a> <em class="jxr_javadoccomment">/** Returns a new default value renderer that separates option parameters from their {@linkplain Option</em>
<a class="jxr_linenumber" name="L3433" href="#L3433">3433</a> <em class="jxr_javadoccomment"> * options} with the specified separator string, surrounds optional parameters with {@code '['} and {@code ']'}</em>
<a class="jxr_linenumber" name="L3434" href="#L3434">3434</a> <em class="jxr_javadoccomment"> * characters and uses ellipses ("...") to indicate that any number of a parameter are allowed.</em>
<a class="jxr_linenumber" name="L3435" href="#L3435">3435</a> <em class="jxr_javadoccomment"> * @return a new default ParamLabelRenderer</em>
<a class="jxr_linenumber" name="L3436" href="#L3436">3436</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3437" href="#L3437">3437</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> createDefaultParamLabelRenderer() {
<a class="jxr_linenumber" name="L3438" href="#L3438">3438</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultParamLabelRenderer</a>(separator);
<a class="jxr_linenumber" name="L3439" href="#L3439">3439</a> }
<a class="jxr_linenumber" name="L3440" href="#L3440">3440</a> <em class="jxr_javadoccomment">/** Sorts Fields annotated with {@code Option} by their option name in case-insensitive alphabetic order. If an</em>
<a class="jxr_linenumber" name="L3441" href="#L3441">3441</a> <em class="jxr_javadoccomment"> * Option has multiple names, the shortest name is used for the sorting. Help options follow non-help options.</em>
<a class="jxr_linenumber" name="L3442" href="#L3442">3442</a> <em class="jxr_javadoccomment"> * @return a comparator that sorts fields by their option name in case-insensitive alphabetic order */</em>
<a class="jxr_linenumber" name="L3443" href="#L3443">3443</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Comparator&lt;Field&gt; createShortOptionNameComparator() {
<a class="jxr_linenumber" name="L3444" href="#L3444">3444</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">SortByShortestOptionNameAlphabetically</a>();
<a class="jxr_linenumber" name="L3445" href="#L3445">3445</a> }
<a class="jxr_linenumber" name="L3446" href="#L3446">3446</a> <em class="jxr_javadoccomment">/** Sorts Fields annotated with {@code Option} by their option {@linkplain Range#max max arity} first, by</em>
<a class="jxr_linenumber" name="L3447" href="#L3447">3447</a> <em class="jxr_javadoccomment"> * {@linkplain Range#min min arity} next, and by {@linkplain #createShortOptionNameComparator() option name} last.</em>
<a class="jxr_linenumber" name="L3448" href="#L3448">3448</a> <em class="jxr_javadoccomment"> * @return a comparator that sorts fields by arity first, then their option name */</em>
<a class="jxr_linenumber" name="L3449" href="#L3449">3449</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Comparator&lt;Field&gt; createShortOptionArityAndNameComparator() {
<a class="jxr_linenumber" name="L3450" href="#L3450">3450</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">SortByOptionArityAndNameAlphabetically</a>();
<a class="jxr_linenumber" name="L3451" href="#L3451">3451</a> }
<a class="jxr_linenumber" name="L3452" href="#L3452">3452</a> <em class="jxr_javadoccomment">/** Sorts short strings before longer strings.</em>
<a class="jxr_linenumber" name="L3453" href="#L3453">3453</a> <em class="jxr_javadoccomment"> * @return a comparators that sorts short strings before longer strings */</em>
<a class="jxr_linenumber" name="L3454" href="#L3454">3454</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Comparator&lt;String&gt; shortestFirst() {
<a class="jxr_linenumber" name="L3455" href="#L3455">3455</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ShortestFirst</a>();
<a class="jxr_linenumber" name="L3456" href="#L3456">3456</a> }
<a class="jxr_linenumber" name="L3457" href="#L3457">3457</a>
<a class="jxr_linenumber" name="L3458" href="#L3458">3458</a> <em class="jxr_javadoccomment">/** Returns whether ANSI escape codes are enabled or not.</em>
<a class="jxr_linenumber" name="L3459" href="#L3459">3459</a> <em class="jxr_javadoccomment"> * @return whether ANSI escape codes are enabled or not</em>
<a class="jxr_linenumber" name="L3460" href="#L3460">3460</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3461" href="#L3461">3461</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi() {
<a class="jxr_linenumber" name="L3462" href="#L3462">3462</a> <strong class="jxr_keyword">return</strong> colorScheme.ansi;
<a class="jxr_linenumber" name="L3463" href="#L3463">3463</a> }
<a class="jxr_linenumber" name="L3464" href="#L3464">3464</a>
<a class="jxr_linenumber" name="L3465" href="#L3465">3465</a> <em class="jxr_javadoccomment">/** When customizing online help for {@link Option Option} details, a custom {@code IOptionRenderer} can be</em>
<a class="jxr_linenumber" name="L3466" href="#L3466">3466</a> <em class="jxr_javadoccomment"> * used to create textual representation of an Option in a tabular format: one or more rows, each containing</em>
<a class="jxr_linenumber" name="L3467" href="#L3467">3467</a> <em class="jxr_javadoccomment"> * one or more columns. The {@link Layout Layout} is responsible for placing these text values in the</em>
<a class="jxr_linenumber" name="L3468" href="#L3468">3468</a> <em class="jxr_javadoccomment"> * {@link TextTable TextTable}. */</em>
<a class="jxr_linenumber" name="L3469" href="#L3469">3469</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IOptionRenderer</a> {
<a class="jxr_linenumber" name="L3470" href="#L3470">3470</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3471" href="#L3471">3471</a> <em class="jxr_javadoccomment"> * Returns a text representation of the specified Option and the Field that captures the option value.</em>
<a class="jxr_linenumber" name="L3472" href="#L3472">3472</a> <em class="jxr_javadoccomment"> * @param option the command line option to show online usage help for</em>
<a class="jxr_linenumber" name="L3473" href="#L3473">3473</a> <em class="jxr_javadoccomment"> * @param field the field that will hold the value for the command line option</em>
<a class="jxr_linenumber" name="L3474" href="#L3474">3474</a> <em class="jxr_javadoccomment"> * @param parameterLabelRenderer responsible for rendering option parameters to text</em>
<a class="jxr_linenumber" name="L3475" href="#L3475">3475</a> <em class="jxr_javadoccomment"> * @param scheme color scheme for applying ansi color styles to options and option parameters</em>
<a class="jxr_linenumber" name="L3476" href="#L3476">3476</a> <em class="jxr_javadoccomment"> * @return a 2-dimensional array of text values: one or more rows, each containing one or more columns</em>
<a class="jxr_linenumber" name="L3477" href="#L3477">3477</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3478" href="#L3478">3478</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] render(<a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option, Field field, <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> parameterLabelRenderer, <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> scheme);
<a class="jxr_linenumber" name="L3479" href="#L3479">3479</a> }
<a class="jxr_linenumber" name="L3480" href="#L3480">3480</a> <em class="jxr_javadoccomment">/** The DefaultOptionRenderer converts {@link Option Options} to five columns of text to match the default</em>
<a class="jxr_linenumber" name="L3481" href="#L3481">3481</a> <em class="jxr_javadoccomment"> * {@linkplain TextTable TextTable} column layout. The first row of values looks like this:</em>
<a class="jxr_linenumber" name="L3482" href="#L3482">3482</a> <em class="jxr_javadoccomment"> * &lt;ol&gt;</em>
<a class="jxr_linenumber" name="L3483" href="#L3483">3483</a> <em class="jxr_javadoccomment"> * &lt;li&gt;the required option marker (if the option is required)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3484" href="#L3484">3484</a> <em class="jxr_javadoccomment"> * &lt;li&gt;2-character short option name (or empty string if no short option exists)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3485" href="#L3485">3485</a> <em class="jxr_javadoccomment"> * &lt;li&gt;comma separator (only if both short option and long option exist, empty string otherwise)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3486" href="#L3486">3486</a> <em class="jxr_javadoccomment"> * &lt;li&gt;comma-separated string with long option name(s)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3487" href="#L3487">3487</a> <em class="jxr_javadoccomment"> * &lt;li&gt;first element of the {@link Option#description()} array&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3488" href="#L3488">3488</a> <em class="jxr_javadoccomment"> * &lt;/ol&gt;</em>
<a class="jxr_linenumber" name="L3489" href="#L3489">3489</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Following this, there will be one row for each of the remaining elements of the {@link</em>
<a class="jxr_linenumber" name="L3490" href="#L3490">3490</a> <em class="jxr_javadoccomment"> * Option#description()} array, and these rows look like {@code {"", "", "", option.description()[i]}}.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3491" href="#L3491">3491</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3492" href="#L3492">3492</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultOptionRenderer</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IOptionRenderer</a> {
<a class="jxr_linenumber" name="L3493" href="#L3493">3493</a> <strong class="jxr_keyword">public</strong> String requiredMarker = <span class="jxr_string">" "</span>;
<a class="jxr_linenumber" name="L3494" href="#L3494">3494</a> <strong class="jxr_keyword">public</strong> Object command;
<a class="jxr_linenumber" name="L3495" href="#L3495">3495</a> <strong class="jxr_keyword">private</strong> String sep;
<a class="jxr_linenumber" name="L3496" href="#L3496">3496</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> showDefault;
<a class="jxr_linenumber" name="L3497" href="#L3497">3497</a> @Override
<a class="jxr_linenumber" name="L3498" href="#L3498">3498</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] render(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option, <strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> paramLabelRenderer, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> scheme) {
<a class="jxr_linenumber" name="L3499" href="#L3499">3499</a> <strong class="jxr_keyword">final</strong> String[] names = ShortestFirst.sort(option.names());
<a class="jxr_linenumber" name="L3500" href="#L3500">3500</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> shortOptionCount = names[0].length() == 2 ? 1 : 0;
<a class="jxr_linenumber" name="L3501" href="#L3501">3501</a> <strong class="jxr_keyword">final</strong> String shortOption = shortOptionCount &gt; 0 ? names[0] : <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L3502" href="#L3502">3502</a> sep = shortOptionCount &gt; 0 &amp;&amp; names.length &gt; 1 ? <span class="jxr_string">","</span> : <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L3503" href="#L3503">3503</a>
<a class="jxr_linenumber" name="L3504" href="#L3504">3504</a> <strong class="jxr_keyword">final</strong> String longOption = join(names, shortOptionCount, names.length - shortOptionCount, <span class="jxr_string">", "</span>);
<a class="jxr_linenumber" name="L3505" href="#L3505">3505</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> longOptionText = createLongOptionText(field, paramLabelRenderer, scheme, longOption);
<a class="jxr_linenumber" name="L3506" href="#L3506">3506</a>
<a class="jxr_linenumber" name="L3507" href="#L3507">3507</a> showDefault = command != <strong class="jxr_keyword">null</strong> &amp;&amp; !option.help() &amp;&amp; !isBoolean(field.getType());
<a class="jxr_linenumber" name="L3508" href="#L3508">3508</a> <strong class="jxr_keyword">final</strong> Object defaultValue = createDefaultValue(field);
<a class="jxr_linenumber" name="L3509" href="#L3509">3509</a>
<a class="jxr_linenumber" name="L3510" href="#L3510">3510</a> <strong class="jxr_keyword">final</strong> String requiredOption = option.required() ? requiredMarker : <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L3511" href="#L3511">3511</a> <strong class="jxr_keyword">return</strong> renderDescriptionLines(option, scheme, requiredOption, shortOption, longOptionText, defaultValue);
<a class="jxr_linenumber" name="L3512" href="#L3512">3512</a> }
<a class="jxr_linenumber" name="L3513" href="#L3513">3513</a>
<a class="jxr_linenumber" name="L3514" href="#L3514">3514</a> <strong class="jxr_keyword">private</strong> Object createDefaultValue(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L3515" href="#L3515">3515</a> Object defaultValue = <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L3516" href="#L3516">3516</a> <strong class="jxr_keyword">try</strong> {
<a class="jxr_linenumber" name="L3517" href="#L3517">3517</a> defaultValue = field.get(command);
<a class="jxr_linenumber" name="L3518" href="#L3518">3518</a> <strong class="jxr_keyword">if</strong> (defaultValue == <strong class="jxr_keyword">null</strong>) { showDefault = false; } <em class="jxr_comment">// #201 don't show null default values</em>
<a class="jxr_linenumber" name="L3519" href="#L3519">3519</a> <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (field.getType().isArray()) {
<a class="jxr_linenumber" name="L3520" href="#L3520">3520</a> <strong class="jxr_keyword">final</strong> StringBuilder sb = <strong class="jxr_keyword">new</strong> StringBuilder();
<a class="jxr_linenumber" name="L3521" href="#L3521">3521</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; Array.getLength(defaultValue); i++) {
<a class="jxr_linenumber" name="L3522" href="#L3522">3522</a> sb.append(i &gt; 0 ? <span class="jxr_string">", "</span> : <span class="jxr_string">""</span>).append(Array.get(defaultValue, i));
<a class="jxr_linenumber" name="L3523" href="#L3523">3523</a> }
<a class="jxr_linenumber" name="L3524" href="#L3524">3524</a> defaultValue = sb.insert(0, <span class="jxr_string">"["</span>).append(<span class="jxr_string">"]"</span>).toString();
<a class="jxr_linenumber" name="L3525" href="#L3525">3525</a> }
<a class="jxr_linenumber" name="L3526" href="#L3526">3526</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ex) {
<a class="jxr_linenumber" name="L3527" href="#L3527">3527</a> showDefault = false;
<a class="jxr_linenumber" name="L3528" href="#L3528">3528</a> }
<a class="jxr_linenumber" name="L3529" href="#L3529">3529</a> <strong class="jxr_keyword">return</strong> defaultValue;
<a class="jxr_linenumber" name="L3530" href="#L3530">3530</a> }
<a class="jxr_linenumber" name="L3531" href="#L3531">3531</a>
<a class="jxr_linenumber" name="L3532" href="#L3532">3532</a> <strong class="jxr_keyword">private</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> createLongOptionText(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> renderer, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> scheme, <strong class="jxr_keyword">final</strong> String longOption) {
<a class="jxr_linenumber" name="L3533" href="#L3533">3533</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> paramLabelText = renderer.renderParameterLabel(field, scheme.ansi(), scheme.optionParamStyles);
<a class="jxr_linenumber" name="L3534" href="#L3534">3534</a>
<a class="jxr_linenumber" name="L3535" href="#L3535">3535</a> <em class="jxr_comment">// if no long option, fill in the space between the short option name and the param label value</em>
<a class="jxr_linenumber" name="L3536" href="#L3536">3536</a> <strong class="jxr_keyword">if</strong> (paramLabelText.length &gt; 0 &amp;&amp; longOption.length() == 0) {
<a class="jxr_linenumber" name="L3537" href="#L3537">3537</a> sep = renderer.separator();
<a class="jxr_linenumber" name="L3538" href="#L3538">3538</a> <em class="jxr_comment">// #181 paramLabelText may be =LABEL or [=LABEL...]</em>
<a class="jxr_linenumber" name="L3539" href="#L3539">3539</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> sepStart = paramLabelText.plainString().indexOf(sep);
<a class="jxr_linenumber" name="L3540" href="#L3540">3540</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> prefix = paramLabelText.substring(0, sepStart);
<a class="jxr_linenumber" name="L3541" href="#L3541">3541</a> paramLabelText = prefix.append(paramLabelText.substring(sepStart + sep.length()));
<a class="jxr_linenumber" name="L3542" href="#L3542">3542</a> }
<a class="jxr_linenumber" name="L3543" href="#L3543">3543</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> longOptionText = scheme.optionText(longOption);
<a class="jxr_linenumber" name="L3544" href="#L3544">3544</a> longOptionText = longOptionText.append(paramLabelText);
<a class="jxr_linenumber" name="L3545" href="#L3545">3545</a> <strong class="jxr_keyword">return</strong> longOptionText;
<a class="jxr_linenumber" name="L3546" href="#L3546">3546</a> }
<a class="jxr_linenumber" name="L3547" href="#L3547">3547</a>
<a class="jxr_linenumber" name="L3548" href="#L3548">3548</a> <strong class="jxr_keyword">private</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] renderDescriptionLines(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option,
<a class="jxr_linenumber" name="L3549" href="#L3549">3549</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> scheme,
<a class="jxr_linenumber" name="L3550" href="#L3550">3550</a> <strong class="jxr_keyword">final</strong> String requiredOption,
<a class="jxr_linenumber" name="L3551" href="#L3551">3551</a> <strong class="jxr_keyword">final</strong> String shortOption,
<a class="jxr_linenumber" name="L3552" href="#L3552">3552</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> longOptionText,
<a class="jxr_linenumber" name="L3553" href="#L3553">3553</a> <strong class="jxr_keyword">final</strong> Object defaultValue) {
<a class="jxr_linenumber" name="L3554" href="#L3554">3554</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> EMPTY = Ansi.EMPTY_TEXT;
<a class="jxr_linenumber" name="L3555" href="#L3555">3555</a> <strong class="jxr_keyword">final</strong> List&lt;Text[]&gt; result = <strong class="jxr_keyword">new</strong> ArrayList&lt;Text[]&gt;();
<a class="jxr_linenumber" name="L3556" href="#L3556">3556</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] descriptionFirstLines = scheme.ansi().<strong class="jxr_keyword">new</strong> Text(str(option.description(), 0)).splitLines();
<a class="jxr_linenumber" name="L3557" href="#L3557">3557</a> <strong class="jxr_keyword">if</strong> (descriptionFirstLines.length == 0) {
<a class="jxr_linenumber" name="L3558" href="#L3558">3558</a> <strong class="jxr_keyword">if</strong> (showDefault) {
<a class="jxr_linenumber" name="L3559" href="#L3559">3559</a> descriptionFirstLines = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[]{scheme.ansi().<strong class="jxr_keyword">new</strong> Text(<span class="jxr_string">" Default: "</span> + defaultValue)};
<a class="jxr_linenumber" name="L3560" href="#L3560">3560</a> showDefault = false; <em class="jxr_comment">// don't show the default value twice</em>
<a class="jxr_linenumber" name="L3561" href="#L3561">3561</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L3562" href="#L3562">3562</a> descriptionFirstLines = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[]{ EMPTY };
<a class="jxr_linenumber" name="L3563" href="#L3563">3563</a> }
<a class="jxr_linenumber" name="L3564" href="#L3564">3564</a> }
<a class="jxr_linenumber" name="L3565" href="#L3565">3565</a> result.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] { scheme.optionText(requiredOption), scheme.optionText(shortOption),
<a class="jxr_linenumber" name="L3566" href="#L3566">3566</a> scheme.ansi().<strong class="jxr_keyword">new</strong> Text(sep), longOptionText, descriptionFirstLines[0] });
<a class="jxr_linenumber" name="L3567" href="#L3567">3567</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 1; i &lt; descriptionFirstLines.length; i++) {
<a class="jxr_linenumber" name="L3568" href="#L3568">3568</a> result.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] { EMPTY, EMPTY, EMPTY, EMPTY, descriptionFirstLines[i] });
<a class="jxr_linenumber" name="L3569" href="#L3569">3569</a> }
<a class="jxr_linenumber" name="L3570" href="#L3570">3570</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 1; i &lt; option.description().length; i++) {
<a class="jxr_linenumber" name="L3571" href="#L3571">3571</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] descriptionNextLines = scheme.ansi().<strong class="jxr_keyword">new</strong> Text(option.description()[i]).splitLines();
<a class="jxr_linenumber" name="L3572" href="#L3572">3572</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Text line : descriptionNextLines) {
<a class="jxr_linenumber" name="L3573" href="#L3573">3573</a> result.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] { EMPTY, EMPTY, EMPTY, EMPTY, line });
<a class="jxr_linenumber" name="L3574" href="#L3574">3574</a> }
<a class="jxr_linenumber" name="L3575" href="#L3575">3575</a> }
<a class="jxr_linenumber" name="L3576" href="#L3576">3576</a> <strong class="jxr_keyword">if</strong> (showDefault) {
<a class="jxr_linenumber" name="L3577" href="#L3577">3577</a> result.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] { EMPTY, EMPTY, EMPTY, EMPTY, scheme.ansi().<strong class="jxr_keyword">new</strong> Text(<span class="jxr_string">" Default: "</span> + defaultValue) });
<a class="jxr_linenumber" name="L3578" href="#L3578">3578</a> }
<a class="jxr_linenumber" name="L3579" href="#L3579">3579</a> <strong class="jxr_keyword">return</strong> result.toArray(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[result.size()][]);
<a class="jxr_linenumber" name="L3580" href="#L3580">3580</a> }
<a class="jxr_linenumber" name="L3581" href="#L3581">3581</a> }
<a class="jxr_linenumber" name="L3582" href="#L3582">3582</a> <em class="jxr_javadoccomment">/** The MinimalOptionRenderer converts {@link Option Options} to a single row with two columns of text: an</em>
<a class="jxr_linenumber" name="L3583" href="#L3583">3583</a> <em class="jxr_javadoccomment"> * option name and a description. If multiple names or description lines exist, the first value is used. */</em>
<a class="jxr_linenumber" name="L3584" href="#L3584">3584</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MinimalOptionRenderer</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IOptionRenderer</a> {
<a class="jxr_linenumber" name="L3585" href="#L3585">3585</a> @Override
<a class="jxr_linenumber" name="L3586" href="#L3586">3586</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] render(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option, <strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> parameterLabelRenderer, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> scheme) {
<a class="jxr_linenumber" name="L3587" href="#L3587">3587</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> optionText = scheme.optionText(option.names()[0]);
<a class="jxr_linenumber" name="L3588" href="#L3588">3588</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> paramLabelText = parameterLabelRenderer.renderParameterLabel(field, scheme.ansi(), scheme.optionParamStyles);
<a class="jxr_linenumber" name="L3589" href="#L3589">3589</a> optionText = optionText.append(paramLabelText);
<a class="jxr_linenumber" name="L3590" href="#L3590">3590</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] {{ optionText,
<a class="jxr_linenumber" name="L3591" href="#L3591">3591</a> scheme.ansi().<strong class="jxr_keyword">new</strong> Text(option.description().length == 0 ? <span class="jxr_string">""</span> : option.description()[0]) }};
<a class="jxr_linenumber" name="L3592" href="#L3592">3592</a> }
<a class="jxr_linenumber" name="L3593" href="#L3593">3593</a> }
<a class="jxr_linenumber" name="L3594" href="#L3594">3594</a> <em class="jxr_javadoccomment">/** The MinimalParameterRenderer converts {@link Parameters Parameters} to a single row with two columns of</em>
<a class="jxr_linenumber" name="L3595" href="#L3595">3595</a> <em class="jxr_javadoccomment"> * text: the parameters label and a description. If multiple description lines exist, the first value is used. */</em>
<a class="jxr_linenumber" name="L3596" href="#L3596">3596</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MinimalParameterRenderer</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParameterRenderer</a> {
<a class="jxr_linenumber" name="L3597" href="#L3597">3597</a> @Override
<a class="jxr_linenumber" name="L3598" href="#L3598">3598</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] render(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Parameters</a> param, <strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> parameterLabelRenderer, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> scheme) {
<a class="jxr_linenumber" name="L3599" href="#L3599">3599</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] {{ parameterLabelRenderer.renderParameterLabel(field, scheme.ansi(), scheme.parameterStyles),
<a class="jxr_linenumber" name="L3600" href="#L3600">3600</a> scheme.ansi().<strong class="jxr_keyword">new</strong> Text(param.description().length == 0 ? <span class="jxr_string">""</span> : param.description()[0]) }};
<a class="jxr_linenumber" name="L3601" href="#L3601">3601</a> }
<a class="jxr_linenumber" name="L3602" href="#L3602">3602</a> }
<a class="jxr_linenumber" name="L3603" href="#L3603">3603</a> <em class="jxr_javadoccomment">/** When customizing online help for {@link Parameters Parameters} details, a custom {@code IParameterRenderer}</em>
<a class="jxr_linenumber" name="L3604" href="#L3604">3604</a> <em class="jxr_javadoccomment"> * can be used to create textual representation of a Parameters field in a tabular format: one or more rows,</em>
<a class="jxr_linenumber" name="L3605" href="#L3605">3605</a> <em class="jxr_javadoccomment"> * each containing one or more columns. The {@link Layout Layout} is responsible for placing these text</em>
<a class="jxr_linenumber" name="L3606" href="#L3606">3606</a> <em class="jxr_javadoccomment"> * values in the {@link TextTable TextTable}. */</em>
<a class="jxr_linenumber" name="L3607" href="#L3607">3607</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParameterRenderer</a> {
<a class="jxr_linenumber" name="L3608" href="#L3608">3608</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3609" href="#L3609">3609</a> <em class="jxr_javadoccomment"> * Returns a text representation of the specified Parameters and the Field that captures the parameter values.</em>
<a class="jxr_linenumber" name="L3610" href="#L3610">3610</a> <em class="jxr_javadoccomment"> * @param parameters the command line parameters to show online usage help for</em>
<a class="jxr_linenumber" name="L3611" href="#L3611">3611</a> <em class="jxr_javadoccomment"> * @param field the field that will hold the value for the command line parameters</em>
<a class="jxr_linenumber" name="L3612" href="#L3612">3612</a> <em class="jxr_javadoccomment"> * @param parameterLabelRenderer responsible for rendering parameter labels to text</em>
<a class="jxr_linenumber" name="L3613" href="#L3613">3613</a> <em class="jxr_javadoccomment"> * @param scheme color scheme for applying ansi color styles to positional parameters</em>
<a class="jxr_linenumber" name="L3614" href="#L3614">3614</a> <em class="jxr_javadoccomment"> * @return a 2-dimensional array of text values: one or more rows, each containing one or more columns</em>
<a class="jxr_linenumber" name="L3615" href="#L3615">3615</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3616" href="#L3616">3616</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] render(<a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Parameters</a> parameters, Field field, <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> parameterLabelRenderer, <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> scheme);
<a class="jxr_linenumber" name="L3617" href="#L3617">3617</a> }
<a class="jxr_linenumber" name="L3618" href="#L3618">3618</a> <em class="jxr_javadoccomment">/** The DefaultParameterRenderer converts {@link Parameters Parameters} to five columns of text to match the</em>
<a class="jxr_linenumber" name="L3619" href="#L3619">3619</a> <em class="jxr_javadoccomment"> * default {@linkplain TextTable TextTable} column layout. The first row of values looks like this:</em>
<a class="jxr_linenumber" name="L3620" href="#L3620">3620</a> <em class="jxr_javadoccomment"> * &lt;ol&gt;</em>
<a class="jxr_linenumber" name="L3621" href="#L3621">3621</a> <em class="jxr_javadoccomment"> * &lt;li&gt;the required option marker (if the parameter's arity is to have at least one value)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3622" href="#L3622">3622</a> <em class="jxr_javadoccomment"> * &lt;li&gt;empty string &lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3623" href="#L3623">3623</a> <em class="jxr_javadoccomment"> * &lt;li&gt;empty string &lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3624" href="#L3624">3624</a> <em class="jxr_javadoccomment"> * &lt;li&gt;parameter(s) label as rendered by the {@link IParamLabelRenderer}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3625" href="#L3625">3625</a> <em class="jxr_javadoccomment"> * &lt;li&gt;first element of the {@link Parameters#description()} array&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3626" href="#L3626">3626</a> <em class="jxr_javadoccomment"> * &lt;/ol&gt;</em>
<a class="jxr_linenumber" name="L3627" href="#L3627">3627</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Following this, there will be one row for each of the remaining elements of the {@link</em>
<a class="jxr_linenumber" name="L3628" href="#L3628">3628</a> <em class="jxr_javadoccomment"> * Parameters#description()} array, and these rows look like {@code {"", "", "", param.description()[i]}}.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3629" href="#L3629">3629</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3630" href="#L3630">3630</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultParameterRenderer</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParameterRenderer</a> {
<a class="jxr_linenumber" name="L3631" href="#L3631">3631</a> <strong class="jxr_keyword">public</strong> String requiredMarker = <span class="jxr_string">" "</span>;
<a class="jxr_linenumber" name="L3632" href="#L3632">3632</a> @Override
<a class="jxr_linenumber" name="L3633" href="#L3633">3633</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] render(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Parameters</a> params, <strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> paramLabelRenderer, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> scheme) {
<a class="jxr_linenumber" name="L3634" href="#L3634">3634</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> label = paramLabelRenderer.renderParameterLabel(field, scheme.ansi(), scheme.parameterStyles);
<a class="jxr_linenumber" name="L3635" href="#L3635">3635</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> requiredParameter = scheme.parameterText(Range.parameterArity(field).min &gt; 0 ? requiredMarker : <span class="jxr_string">""</span>);
<a class="jxr_linenumber" name="L3636" href="#L3636">3636</a>
<a class="jxr_linenumber" name="L3637" href="#L3637">3637</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> EMPTY = Ansi.EMPTY_TEXT;
<a class="jxr_linenumber" name="L3638" href="#L3638">3638</a> <strong class="jxr_keyword">final</strong> List&lt;Text[]&gt; result = <strong class="jxr_keyword">new</strong> ArrayList&lt;Text[]&gt;();
<a class="jxr_linenumber" name="L3639" href="#L3639">3639</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] descriptionFirstLines = scheme.ansi().<strong class="jxr_keyword">new</strong> Text(str(params.description(), 0)).splitLines();
<a class="jxr_linenumber" name="L3640" href="#L3640">3640</a> <strong class="jxr_keyword">if</strong> (descriptionFirstLines.length == 0) { descriptionFirstLines = <strong class="jxr_keyword">new</strong> Text[]{ EMPTY }; }
<a class="jxr_linenumber" name="L3641" href="#L3641">3641</a> result.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] { requiredParameter, EMPTY, EMPTY, label, descriptionFirstLines[0] });
<a class="jxr_linenumber" name="L3642" href="#L3642">3642</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 1; i &lt; descriptionFirstLines.length; i++) {
<a class="jxr_linenumber" name="L3643" href="#L3643">3643</a> result.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] { EMPTY, EMPTY, EMPTY, EMPTY, descriptionFirstLines[i] });
<a class="jxr_linenumber" name="L3644" href="#L3644">3644</a> }
<a class="jxr_linenumber" name="L3645" href="#L3645">3645</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 1; i &lt; params.description().length; i++) {
<a class="jxr_linenumber" name="L3646" href="#L3646">3646</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] descriptionNextLines = scheme.ansi().<strong class="jxr_keyword">new</strong> Text(params.description()[i]).splitLines();
<a class="jxr_linenumber" name="L3647" href="#L3647">3647</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Text line : descriptionNextLines) {
<a class="jxr_linenumber" name="L3648" href="#L3648">3648</a> result.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] { EMPTY, EMPTY, EMPTY, EMPTY, line });
<a class="jxr_linenumber" name="L3649" href="#L3649">3649</a> }
<a class="jxr_linenumber" name="L3650" href="#L3650">3650</a> }
<a class="jxr_linenumber" name="L3651" href="#L3651">3651</a> <strong class="jxr_keyword">return</strong> result.toArray(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[result.size()][]);
<a class="jxr_linenumber" name="L3652" href="#L3652">3652</a> }
<a class="jxr_linenumber" name="L3653" href="#L3653">3653</a> }
<a class="jxr_linenumber" name="L3654" href="#L3654">3654</a> <em class="jxr_javadoccomment">/** When customizing online usage help for an option parameter or a positional parameter, a custom</em>
<a class="jxr_linenumber" name="L3655" href="#L3655">3655</a> <em class="jxr_javadoccomment"> * {@code IParamLabelRenderer} can be used to render the parameter name or label to a String. */</em>
<a class="jxr_linenumber" name="L3656" href="#L3656">3656</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> {
<a class="jxr_linenumber" name="L3657" href="#L3657">3657</a>
<a class="jxr_linenumber" name="L3658" href="#L3658">3658</a> <em class="jxr_javadoccomment">/** Returns a text rendering of the Option parameter or positional parameter; returns an empty string</em>
<a class="jxr_linenumber" name="L3659" href="#L3659">3659</a> <em class="jxr_javadoccomment"> * {@code ""} if the option is a boolean and does not take a parameter.</em>
<a class="jxr_linenumber" name="L3660" href="#L3660">3660</a> <em class="jxr_javadoccomment"> * @param field the annotated field with a parameter label</em>
<a class="jxr_linenumber" name="L3661" href="#L3661">3661</a> <em class="jxr_javadoccomment"> * @param ansi determines whether ANSI escape codes should be emitted or not</em>
<a class="jxr_linenumber" name="L3662" href="#L3662">3662</a> <em class="jxr_javadoccomment"> * @param styles the styles to apply to the parameter label</em>
<a class="jxr_linenumber" name="L3663" href="#L3663">3663</a> <em class="jxr_javadoccomment"> * @return a text rendering of the Option parameter or positional parameter */</em>
<a class="jxr_linenumber" name="L3664" href="#L3664">3664</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> renderParameterLabel(Field field, <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi, List&lt;IStyle&gt; styles);
<a class="jxr_linenumber" name="L3665" href="#L3665">3665</a>
<a class="jxr_linenumber" name="L3666" href="#L3666">3666</a> <em class="jxr_javadoccomment">/** Returns the separator between option name and param label.</em>
<a class="jxr_linenumber" name="L3667" href="#L3667">3667</a> <em class="jxr_javadoccomment"> * @return the separator between option name and param label */</em>
<a class="jxr_linenumber" name="L3668" href="#L3668">3668</a> String separator();
<a class="jxr_linenumber" name="L3669" href="#L3669">3669</a> }
<a class="jxr_linenumber" name="L3670" href="#L3670">3670</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3671" href="#L3671">3671</a> <em class="jxr_javadoccomment"> * DefaultParamLabelRenderer separates option parameters from their {@linkplain Option options} with a</em>
<a class="jxr_linenumber" name="L3672" href="#L3672">3672</a> <em class="jxr_javadoccomment"> * {@linkplain DefaultParamLabelRenderer#separator separator} string, surrounds optional values</em>
<a class="jxr_linenumber" name="L3673" href="#L3673">3673</a> <em class="jxr_javadoccomment"> * with {@code '['} and {@code ']'} characters and uses ellipses ("...") to indicate that any number of</em>
<a class="jxr_linenumber" name="L3674" href="#L3674">3674</a> <em class="jxr_javadoccomment"> * values is allowed for options or parameters with variable arity.</em>
<a class="jxr_linenumber" name="L3675" href="#L3675">3675</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3676" href="#L3676">3676</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultParamLabelRenderer</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> {
<a class="jxr_linenumber" name="L3677" href="#L3677">3677</a> <em class="jxr_javadoccomment">/** The string to use to separate option parameters from their options. */</em>
<a class="jxr_linenumber" name="L3678" href="#L3678">3678</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> String separator;
<a class="jxr_linenumber" name="L3679" href="#L3679">3679</a> <em class="jxr_javadoccomment">/** Constructs a new DefaultParamLabelRenderer with the specified separator string. */</em>
<a class="jxr_linenumber" name="L3680" href="#L3680">3680</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultParamLabelRenderer</a>(<strong class="jxr_keyword">final</strong> String separator) {
<a class="jxr_linenumber" name="L3681" href="#L3681">3681</a> <strong class="jxr_keyword">this</strong>.separator = Assert.notNull(separator, <span class="jxr_string">"separator"</span>);
<a class="jxr_linenumber" name="L3682" href="#L3682">3682</a> }
<a class="jxr_linenumber" name="L3683" href="#L3683">3683</a> @Override
<a class="jxr_linenumber" name="L3684" href="#L3684">3684</a> <strong class="jxr_keyword">public</strong> String separator() { <strong class="jxr_keyword">return</strong> separator; }
<a class="jxr_linenumber" name="L3685" href="#L3685">3685</a> @Override
<a class="jxr_linenumber" name="L3686" href="#L3686">3686</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> renderParameterLabel(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi, <strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; styles) {
<a class="jxr_linenumber" name="L3687" href="#L3687">3687</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> isOptionParameter = field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3688" href="#L3688">3688</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity = isOptionParameter ? Range.optionArity(field) : Range.parameterCapacity(field);
<a class="jxr_linenumber" name="L3689" href="#L3689">3689</a> <strong class="jxr_keyword">final</strong> String split = isOptionParameter ? field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).split() : field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).split();
<a class="jxr_linenumber" name="L3690" href="#L3690">3690</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> result = ansi.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(<span class="jxr_string">""</span>);
<a class="jxr_linenumber" name="L3691" href="#L3691">3691</a> String sep = isOptionParameter ? separator : <span class="jxr_string">""</span>;
<a class="jxr_linenumber" name="L3692" href="#L3692">3692</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> paramName = ansi.apply(renderParameterName(field), styles);
<a class="jxr_linenumber" name="L3693" href="#L3693">3693</a> <strong class="jxr_keyword">if</strong> (!empty(split)) { paramName = paramName.append(<span class="jxr_string">"["</span> + split).append(paramName).append(<span class="jxr_string">"]..."</span>); } <em class="jxr_comment">// #194</em>
<a class="jxr_linenumber" name="L3694" href="#L3694">3694</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; arity.min; i++) {
<a class="jxr_linenumber" name="L3695" href="#L3695">3695</a> result = result.append(sep).append(paramName);
<a class="jxr_linenumber" name="L3696" href="#L3696">3696</a> sep = <span class="jxr_string">" "</span>;
<a class="jxr_linenumber" name="L3697" href="#L3697">3697</a> }
<a class="jxr_linenumber" name="L3698" href="#L3698">3698</a> <strong class="jxr_keyword">if</strong> (arity.isVariable) {
<a class="jxr_linenumber" name="L3699" href="#L3699">3699</a> <strong class="jxr_keyword">if</strong> (result.length == 0) { <em class="jxr_comment">// arity="*" or arity="0..*"</em>
<a class="jxr_linenumber" name="L3700" href="#L3700">3700</a> result = result.append(sep + <span class="jxr_string">"["</span>).append(paramName).append(<span class="jxr_string">"]..."</span>);
<a class="jxr_linenumber" name="L3701" href="#L3701">3701</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (!result.plainString().endsWith(<span class="jxr_string">"..."</span>)) { <em class="jxr_comment">// split param may already end with "..."</em>
<a class="jxr_linenumber" name="L3702" href="#L3702">3702</a> result = result.append(<span class="jxr_string">"..."</span>);
<a class="jxr_linenumber" name="L3703" href="#L3703">3703</a> }
<a class="jxr_linenumber" name="L3704" href="#L3704">3704</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L3705" href="#L3705">3705</a> sep = result.length == 0 ? (isOptionParameter ? separator : <span class="jxr_string">""</span>) : <span class="jxr_string">" "</span>;
<a class="jxr_linenumber" name="L3706" href="#L3706">3706</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = arity.min; i &lt; arity.max; i++) {
<a class="jxr_linenumber" name="L3707" href="#L3707">3707</a> <strong class="jxr_keyword">if</strong> (sep.trim().length() == 0) {
<a class="jxr_linenumber" name="L3708" href="#L3708">3708</a> result = result.append(sep + <span class="jxr_string">"["</span>).append(paramName);
<a class="jxr_linenumber" name="L3709" href="#L3709">3709</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L3710" href="#L3710">3710</a> result = result.append(<span class="jxr_string">"["</span> + sep).append(paramName);
<a class="jxr_linenumber" name="L3711" href="#L3711">3711</a> }
<a class="jxr_linenumber" name="L3712" href="#L3712">3712</a> sep = <span class="jxr_string">" "</span>;
<a class="jxr_linenumber" name="L3713" href="#L3713">3713</a> }
<a class="jxr_linenumber" name="L3714" href="#L3714">3714</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = arity.min; i &lt; arity.max; i++) { result = result.append(<span class="jxr_string">"]"</span>); }
<a class="jxr_linenumber" name="L3715" href="#L3715">3715</a> }
<a class="jxr_linenumber" name="L3716" href="#L3716">3716</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L3717" href="#L3717">3717</a> }
<a class="jxr_linenumber" name="L3718" href="#L3718">3718</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String renderParameterName(<strong class="jxr_keyword">final</strong> Field field) {
<a class="jxr_linenumber" name="L3719" href="#L3719">3719</a> String result = <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L3720" href="#L3720">3720</a> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L3721" href="#L3721">3721</a> result = field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).paramLabel();
<a class="jxr_linenumber" name="L3722" href="#L3722">3722</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (field.isAnnotationPresent(Parameters.<strong class="jxr_keyword">class</strong>)) {
<a class="jxr_linenumber" name="L3723" href="#L3723">3723</a> result = field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).paramLabel();
<a class="jxr_linenumber" name="L3724" href="#L3724">3724</a> }
<a class="jxr_linenumber" name="L3725" href="#L3725">3725</a> <strong class="jxr_keyword">if</strong> (result != <strong class="jxr_keyword">null</strong> &amp;&amp; result.trim().length() &gt; 0) {
<a class="jxr_linenumber" name="L3726" href="#L3726">3726</a> <strong class="jxr_keyword">return</strong> result.trim();
<a class="jxr_linenumber" name="L3727" href="#L3727">3727</a> }
<a class="jxr_linenumber" name="L3728" href="#L3728">3728</a> String name = field.getName();
<a class="jxr_linenumber" name="L3729" href="#L3729">3729</a> <strong class="jxr_keyword">if</strong> (Map.<strong class="jxr_keyword">class</strong>.isAssignableFrom(field.getType())) { <em class="jxr_comment">// #195 better param labels for map fields</em>
<a class="jxr_linenumber" name="L3730" href="#L3730">3730</a> <strong class="jxr_keyword">final</strong> Class&lt;?&gt;[] paramTypes = getTypeAttribute(field);
<a class="jxr_linenumber" name="L3731" href="#L3731">3731</a> <strong class="jxr_keyword">if</strong> (paramTypes.length &lt; 2 || paramTypes[0] == <strong class="jxr_keyword">null</strong> || paramTypes[1] == <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L3732" href="#L3732">3732</a> name = <span class="jxr_string">"String=String"</span>;
<a class="jxr_linenumber" name="L3733" href="#L3733">3733</a> } <strong class="jxr_keyword">else</strong> { name = paramTypes[0].getSimpleName() + <span class="jxr_string">"="</span> + paramTypes[1].getSimpleName(); }
<a class="jxr_linenumber" name="L3734" href="#L3734">3734</a> }
<a class="jxr_linenumber" name="L3735" href="#L3735">3735</a> <strong class="jxr_keyword">return</strong> <span class="jxr_string">"&lt;"</span> + name + <span class="jxr_string">"&gt;"</span>;
<a class="jxr_linenumber" name="L3736" href="#L3736">3736</a> }
<a class="jxr_linenumber" name="L3737" href="#L3737">3737</a> }
<a class="jxr_linenumber" name="L3738" href="#L3738">3738</a> <em class="jxr_javadoccomment">/** Use a Layout to format usage help text for options and parameters in tabular format.</em>
<a class="jxr_linenumber" name="L3739" href="#L3739">3739</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Delegates to the renderers to create {@link Text} values for the annotated fields, and uses a</em>
<a class="jxr_linenumber" name="L3740" href="#L3740">3740</a> <em class="jxr_javadoccomment"> * {@link TextTable} to display these values in tabular format. Layout is responsible for deciding which values</em>
<a class="jxr_linenumber" name="L3741" href="#L3741">3741</a> <em class="jxr_javadoccomment"> * to display where in the table. By default, Layout shows one option or parameter per table row.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3742" href="#L3742">3742</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Customize by overriding the {@link #layout(Field, CommandLine.Help.Ansi.Text[][])} method.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3743" href="#L3743">3743</a> <em class="jxr_javadoccomment"> * @see IOptionRenderer rendering options to text</em>
<a class="jxr_linenumber" name="L3744" href="#L3744">3744</a> <em class="jxr_javadoccomment"> * @see IParameterRenderer rendering parameters to text</em>
<a class="jxr_linenumber" name="L3745" href="#L3745">3745</a> <em class="jxr_javadoccomment"> * @see TextTable showing values in a tabular format</em>
<a class="jxr_linenumber" name="L3746" href="#L3746">3746</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3747" href="#L3747">3747</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Layout</a> {
<a class="jxr_linenumber" name="L3748" href="#L3748">3748</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> colorScheme;
<a class="jxr_linenumber" name="L3749" href="#L3749">3749</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a> table;
<a class="jxr_linenumber" name="L3750" href="#L3750">3750</a> <strong class="jxr_keyword">protected</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IOptionRenderer</a> optionRenderer;
<a class="jxr_linenumber" name="L3751" href="#L3751">3751</a> <strong class="jxr_keyword">protected</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParameterRenderer</a> parameterRenderer;
<a class="jxr_linenumber" name="L3752" href="#L3752">3752</a>
<a class="jxr_linenumber" name="L3753" href="#L3753">3753</a> <em class="jxr_javadoccomment">/** Constructs a Layout with the specified color scheme, a new default TextTable, the</em>
<a class="jxr_linenumber" name="L3754" href="#L3754">3754</a> <em class="jxr_javadoccomment"> * {@linkplain Help#createDefaultOptionRenderer() default option renderer}, and the</em>
<a class="jxr_linenumber" name="L3755" href="#L3755">3755</a> <em class="jxr_javadoccomment"> * {@linkplain Help#createDefaultParameterRenderer() default parameter renderer}.</em>
<a class="jxr_linenumber" name="L3756" href="#L3756">3756</a> <em class="jxr_javadoccomment"> * @param colorScheme the color scheme to use for common, auto-generated parts of the usage help message */</em>
<a class="jxr_linenumber" name="L3757" href="#L3757">3757</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Layout</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> colorScheme) { <strong class="jxr_keyword">this</strong>(colorScheme, <strong class="jxr_keyword">new</strong> TextTable(colorScheme.ansi())); }
<a class="jxr_linenumber" name="L3758" href="#L3758">3758</a>
<a class="jxr_linenumber" name="L3759" href="#L3759">3759</a> <em class="jxr_javadoccomment">/** Constructs a Layout with the specified color scheme, the specified TextTable, the</em>
<a class="jxr_linenumber" name="L3760" href="#L3760">3760</a> <em class="jxr_javadoccomment"> * {@linkplain Help#createDefaultOptionRenderer() default option renderer}, and the</em>
<a class="jxr_linenumber" name="L3761" href="#L3761">3761</a> <em class="jxr_javadoccomment"> * {@linkplain Help#createDefaultParameterRenderer() default parameter renderer}.</em>
<a class="jxr_linenumber" name="L3762" href="#L3762">3762</a> <em class="jxr_javadoccomment"> * @param colorScheme the color scheme to use for common, auto-generated parts of the usage help message</em>
<a class="jxr_linenumber" name="L3763" href="#L3763">3763</a> <em class="jxr_javadoccomment"> * @param textTable the TextTable to lay out parts of the usage help message in tabular format */</em>
<a class="jxr_linenumber" name="L3764" href="#L3764">3764</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Layout</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> colorScheme, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a> textTable) {
<a class="jxr_linenumber" name="L3765" href="#L3765">3765</a> <strong class="jxr_keyword">this</strong>(colorScheme, textTable, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DefaultOptionRenderer</a>(), <strong class="jxr_keyword">new</strong> DefaultParameterRenderer());
<a class="jxr_linenumber" name="L3766" href="#L3766">3766</a> }
<a class="jxr_linenumber" name="L3767" href="#L3767">3767</a> <em class="jxr_javadoccomment">/** Constructs a Layout with the specified color scheme, the specified TextTable, the</em>
<a class="jxr_linenumber" name="L3768" href="#L3768">3768</a> <em class="jxr_javadoccomment"> * specified option renderer and the specified parameter renderer.</em>
<a class="jxr_linenumber" name="L3769" href="#L3769">3769</a> <em class="jxr_javadoccomment"> * @param colorScheme the color scheme to use for common, auto-generated parts of the usage help message</em>
<a class="jxr_linenumber" name="L3770" href="#L3770">3770</a> <em class="jxr_javadoccomment"> * @param optionRenderer the object responsible for rendering Options to Text</em>
<a class="jxr_linenumber" name="L3771" href="#L3771">3771</a> <em class="jxr_javadoccomment"> * @param parameterRenderer the object responsible for rendering Parameters to Text</em>
<a class="jxr_linenumber" name="L3772" href="#L3772">3772</a> <em class="jxr_javadoccomment"> * @param textTable the TextTable to lay out parts of the usage help message in tabular format */</em>
<a class="jxr_linenumber" name="L3773" href="#L3773">3773</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Layout</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> colorScheme, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a> textTable, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IOptionRenderer</a> optionRenderer, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParameterRenderer</a> parameterRenderer) {
<a class="jxr_linenumber" name="L3774" href="#L3774">3774</a> <strong class="jxr_keyword">this</strong>.colorScheme = Assert.notNull(colorScheme, <span class="jxr_string">"colorScheme"</span>);
<a class="jxr_linenumber" name="L3775" href="#L3775">3775</a> <strong class="jxr_keyword">this</strong>.table = Assert.notNull(textTable, <span class="jxr_string">"textTable"</span>);
<a class="jxr_linenumber" name="L3776" href="#L3776">3776</a> <strong class="jxr_keyword">this</strong>.optionRenderer = Assert.notNull(optionRenderer, <span class="jxr_string">"optionRenderer"</span>);
<a class="jxr_linenumber" name="L3777" href="#L3777">3777</a> <strong class="jxr_keyword">this</strong>.parameterRenderer = Assert.notNull(parameterRenderer, <span class="jxr_string">"parameterRenderer"</span>);
<a class="jxr_linenumber" name="L3778" href="#L3778">3778</a> }
<a class="jxr_linenumber" name="L3779" href="#L3779">3779</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3780" href="#L3780">3780</a> <em class="jxr_javadoccomment"> * Copies the specified text values into the correct cells in the {@link TextTable}. This implementation</em>
<a class="jxr_linenumber" name="L3781" href="#L3781">3781</a> <em class="jxr_javadoccomment"> * delegates to {@link TextTable#addRowValues(CommandLine.Help.Ansi.Text...)} for each row of values.</em>
<a class="jxr_linenumber" name="L3782" href="#L3782">3782</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Subclasses may override.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3783" href="#L3783">3783</a> <em class="jxr_javadoccomment"> * @param field the field annotated with the specified Option or Parameters</em>
<a class="jxr_linenumber" name="L3784" href="#L3784">3784</a> <em class="jxr_javadoccomment"> * @param cellValues the text values representing the Option/Parameters, to be displayed in tabular form</em>
<a class="jxr_linenumber" name="L3785" href="#L3785">3785</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3786" href="#L3786">3786</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> layout(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] cellValues) {
<a class="jxr_linenumber" name="L3787" href="#L3787">3787</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Text[] oneRow : cellValues) {
<a class="jxr_linenumber" name="L3788" href="#L3788">3788</a> table.addRowValues(oneRow);
<a class="jxr_linenumber" name="L3789" href="#L3789">3789</a> }
<a class="jxr_linenumber" name="L3790" href="#L3790">3790</a> }
<a class="jxr_linenumber" name="L3791" href="#L3791">3791</a> <em class="jxr_javadoccomment">/** Calls {@link #addOption(Field, CommandLine.Help.IParamLabelRenderer)} for all non-hidden Options in the list.</em>
<a class="jxr_linenumber" name="L3792" href="#L3792">3792</a> <em class="jxr_javadoccomment"> * @param fields fields annotated with {@link Option} to add usage descriptions for</em>
<a class="jxr_linenumber" name="L3793" href="#L3793">3793</a> <em class="jxr_javadoccomment"> * @param paramLabelRenderer object that knows how to render option parameters */</em>
<a class="jxr_linenumber" name="L3794" href="#L3794">3794</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> addOptions(<strong class="jxr_keyword">final</strong> List&lt;Field&gt; fields, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> paramLabelRenderer) {
<a class="jxr_linenumber" name="L3795" href="#L3795">3795</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field field : fields) {
<a class="jxr_linenumber" name="L3796" href="#L3796">3796</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option = field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3797" href="#L3797">3797</a> <strong class="jxr_keyword">if</strong> (!option.hidden()) {
<a class="jxr_linenumber" name="L3798" href="#L3798">3798</a> addOption(field, paramLabelRenderer);
<a class="jxr_linenumber" name="L3799" href="#L3799">3799</a> }
<a class="jxr_linenumber" name="L3800" href="#L3800">3800</a> }
<a class="jxr_linenumber" name="L3801" href="#L3801">3801</a> }
<a class="jxr_linenumber" name="L3802" href="#L3802">3802</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3803" href="#L3803">3803</a> <em class="jxr_javadoccomment"> * Delegates to the {@link #optionRenderer option renderer} of this layout to obtain</em>
<a class="jxr_linenumber" name="L3804" href="#L3804">3804</a> <em class="jxr_javadoccomment"> * text values for the specified {@link Option}, and then calls the {@link #layout(Field, CommandLine.Help.Ansi.Text[][])}</em>
<a class="jxr_linenumber" name="L3805" href="#L3805">3805</a> <em class="jxr_javadoccomment"> * method to write these text values into the correct cells in the TextTable.</em>
<a class="jxr_linenumber" name="L3806" href="#L3806">3806</a> <em class="jxr_javadoccomment"> * @param field the field annotated with the specified Option</em>
<a class="jxr_linenumber" name="L3807" href="#L3807">3807</a> <em class="jxr_javadoccomment"> * @param paramLabelRenderer knows how to render option parameters</em>
<a class="jxr_linenumber" name="L3808" href="#L3808">3808</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3809" href="#L3809">3809</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> addOption(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> paramLabelRenderer) {
<a class="jxr_linenumber" name="L3810" href="#L3810">3810</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> option = field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3811" href="#L3811">3811</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] values = optionRenderer.render(option, field, paramLabelRenderer, colorScheme);
<a class="jxr_linenumber" name="L3812" href="#L3812">3812</a> layout(field, values);
<a class="jxr_linenumber" name="L3813" href="#L3813">3813</a> }
<a class="jxr_linenumber" name="L3814" href="#L3814">3814</a> <em class="jxr_javadoccomment">/** Calls {@link #addPositionalParameter(Field, CommandLine.Help.IParamLabelRenderer)} for all non-hidden Parameters in the list.</em>
<a class="jxr_linenumber" name="L3815" href="#L3815">3815</a> <em class="jxr_javadoccomment"> * @param fields fields annotated with {@link Parameters} to add usage descriptions for</em>
<a class="jxr_linenumber" name="L3816" href="#L3816">3816</a> <em class="jxr_javadoccomment"> * @param paramLabelRenderer knows how to render option parameters */</em>
<a class="jxr_linenumber" name="L3817" href="#L3817">3817</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> addPositionalParameters(<strong class="jxr_keyword">final</strong> List&lt;Field&gt; fields, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> paramLabelRenderer) {
<a class="jxr_linenumber" name="L3818" href="#L3818">3818</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field field : fields) {
<a class="jxr_linenumber" name="L3819" href="#L3819">3819</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Parameters</a> parameters = field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3820" href="#L3820">3820</a> <strong class="jxr_keyword">if</strong> (!parameters.hidden()) {
<a class="jxr_linenumber" name="L3821" href="#L3821">3821</a> addPositionalParameter(field, paramLabelRenderer);
<a class="jxr_linenumber" name="L3822" href="#L3822">3822</a> }
<a class="jxr_linenumber" name="L3823" href="#L3823">3823</a> }
<a class="jxr_linenumber" name="L3824" href="#L3824">3824</a> }
<a class="jxr_linenumber" name="L3825" href="#L3825">3825</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3826" href="#L3826">3826</a> <em class="jxr_javadoccomment"> * Delegates to the {@link #parameterRenderer parameter renderer} of this layout</em>
<a class="jxr_linenumber" name="L3827" href="#L3827">3827</a> <em class="jxr_javadoccomment"> * to obtain text values for the specified {@link Parameters}, and then calls</em>
<a class="jxr_linenumber" name="L3828" href="#L3828">3828</a> <em class="jxr_javadoccomment"> * {@link #layout(Field, CommandLine.Help.Ansi.Text[][])} to write these text values into the correct cells in the TextTable.</em>
<a class="jxr_linenumber" name="L3829" href="#L3829">3829</a> <em class="jxr_javadoccomment"> * @param field the field annotated with the specified Parameters</em>
<a class="jxr_linenumber" name="L3830" href="#L3830">3830</a> <em class="jxr_javadoccomment"> * @param paramLabelRenderer knows how to render option parameters</em>
<a class="jxr_linenumber" name="L3831" href="#L3831">3831</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3832" href="#L3832">3832</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> addPositionalParameter(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IParamLabelRenderer</a> paramLabelRenderer) {
<a class="jxr_linenumber" name="L3833" href="#L3833">3833</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Parameters</a> option = field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3834" href="#L3834">3834</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[][] values = parameterRenderer.render(option, field, paramLabelRenderer, colorScheme);
<a class="jxr_linenumber" name="L3835" href="#L3835">3835</a> layout(field, values);
<a class="jxr_linenumber" name="L3836" href="#L3836">3836</a> }
<a class="jxr_linenumber" name="L3837" href="#L3837">3837</a> <em class="jxr_javadoccomment">/** Returns the section of the usage help message accumulated in the TextTable owned by this layout. */</em>
<a class="jxr_linenumber" name="L3838" href="#L3838">3838</a> @Override <strong class="jxr_keyword">public</strong> String toString() {
<a class="jxr_linenumber" name="L3839" href="#L3839">3839</a> <strong class="jxr_keyword">return</strong> table.toString();
<a class="jxr_linenumber" name="L3840" href="#L3840">3840</a> }
<a class="jxr_linenumber" name="L3841" href="#L3841">3841</a> }
<a class="jxr_linenumber" name="L3842" href="#L3842">3842</a> <em class="jxr_javadoccomment">/** Sorts short strings before longer strings. */</em>
<a class="jxr_linenumber" name="L3843" href="#L3843">3843</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ShortestFirst</a> <strong class="jxr_keyword">implements</strong> Comparator&lt;String&gt; {
<a class="jxr_linenumber" name="L3844" href="#L3844">3844</a> @Override
<a class="jxr_linenumber" name="L3845" href="#L3845">3845</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> compare(<strong class="jxr_keyword">final</strong> String o1, <strong class="jxr_keyword">final</strong> String o2) {
<a class="jxr_linenumber" name="L3846" href="#L3846">3846</a> <strong class="jxr_keyword">return</strong> o1.length() - o2.length();
<a class="jxr_linenumber" name="L3847" href="#L3847">3847</a> }
<a class="jxr_linenumber" name="L3848" href="#L3848">3848</a> <em class="jxr_javadoccomment">/** Sorts the specified array of Strings shortest-first and returns it. */</em>
<a class="jxr_linenumber" name="L3849" href="#L3849">3849</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String[] sort(<strong class="jxr_keyword">final</strong> String[] names) {
<a class="jxr_linenumber" name="L3850" href="#L3850">3850</a> Arrays.sort(names, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ShortestFirst</a>());
<a class="jxr_linenumber" name="L3851" href="#L3851">3851</a> <strong class="jxr_keyword">return</strong> names;
<a class="jxr_linenumber" name="L3852" href="#L3852">3852</a> }
<a class="jxr_linenumber" name="L3853" href="#L3853">3853</a> }
<a class="jxr_linenumber" name="L3854" href="#L3854">3854</a> <em class="jxr_javadoccomment">/** Sorts {@code Option} instances by their name in case-insensitive alphabetic order. If an Option has</em>
<a class="jxr_linenumber" name="L3855" href="#L3855">3855</a> <em class="jxr_javadoccomment"> * multiple names, the shortest name is used for the sorting. Help options follow non-help options. */</em>
<a class="jxr_linenumber" name="L3856" href="#L3856">3856</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">SortByShortestOptionNameAlphabetically</a> <strong class="jxr_keyword">implements</strong> Comparator&lt;Field&gt; {
<a class="jxr_linenumber" name="L3857" href="#L3857">3857</a> @Override
<a class="jxr_linenumber" name="L3858" href="#L3858">3858</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> compare(<strong class="jxr_keyword">final</strong> Field f1, <strong class="jxr_keyword">final</strong> Field f2) {
<a class="jxr_linenumber" name="L3859" href="#L3859">3859</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> o1 = f1.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3860" href="#L3860">3860</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> o2 = f2.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3861" href="#L3861">3861</a> <strong class="jxr_keyword">if</strong> (o1 == <strong class="jxr_keyword">null</strong>) { <strong class="jxr_keyword">return</strong> 1; } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (o2 == <strong class="jxr_keyword">null</strong>) { <strong class="jxr_keyword">return</strong> -1; } <em class="jxr_comment">// options before params</em>
<a class="jxr_linenumber" name="L3862" href="#L3862">3862</a> <strong class="jxr_keyword">final</strong> String[] names1 = ShortestFirst.sort(o1.names());
<a class="jxr_linenumber" name="L3863" href="#L3863">3863</a> <strong class="jxr_keyword">final</strong> String[] names2 = ShortestFirst.sort(o2.names());
<a class="jxr_linenumber" name="L3864" href="#L3864">3864</a> <strong class="jxr_keyword">int</strong> result = names1[0].toUpperCase().compareTo(names2[0].toUpperCase()); <em class="jxr_comment">// case insensitive sort</em>
<a class="jxr_linenumber" name="L3865" href="#L3865">3865</a> result = result == 0 ? -names1[0].compareTo(names2[0]) : result; <em class="jxr_comment">// lower case before upper case</em>
<a class="jxr_linenumber" name="L3866" href="#L3866">3866</a> <strong class="jxr_keyword">return</strong> o1.help() == o2.help() ? result : o2.help() ? -1 : 1; <em class="jxr_comment">// help options come last</em>
<a class="jxr_linenumber" name="L3867" href="#L3867">3867</a> }
<a class="jxr_linenumber" name="L3868" href="#L3868">3868</a> }
<a class="jxr_linenumber" name="L3869" href="#L3869">3869</a> <em class="jxr_javadoccomment">/** Sorts {@code Option} instances by their max arity first, then their min arity, then delegates to super class. */</em>
<a class="jxr_linenumber" name="L3870" href="#L3870">3870</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">SortByOptionArityAndNameAlphabetically</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">SortByShortestOptionNameAlphabetically</a> {
<a class="jxr_linenumber" name="L3871" href="#L3871">3871</a> @Override
<a class="jxr_linenumber" name="L3872" href="#L3872">3872</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> compare(<strong class="jxr_keyword">final</strong> Field f1, <strong class="jxr_keyword">final</strong> Field f2) {
<a class="jxr_linenumber" name="L3873" href="#L3873">3873</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> o1 = f1.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3874" href="#L3874">3874</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Option</a> o2 = f2.getAnnotation(Option.<strong class="jxr_keyword">class</strong>);
<a class="jxr_linenumber" name="L3875" href="#L3875">3875</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity1 = Range.optionArity(f1);
<a class="jxr_linenumber" name="L3876" href="#L3876">3876</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Range</a> arity2 = Range.optionArity(f2);
<a class="jxr_linenumber" name="L3877" href="#L3877">3877</a> <strong class="jxr_keyword">int</strong> result = arity1.max - arity2.max;
<a class="jxr_linenumber" name="L3878" href="#L3878">3878</a> <strong class="jxr_keyword">if</strong> (result == 0) {
<a class="jxr_linenumber" name="L3879" href="#L3879">3879</a> result = arity1.min - arity2.min;
<a class="jxr_linenumber" name="L3880" href="#L3880">3880</a> }
<a class="jxr_linenumber" name="L3881" href="#L3881">3881</a> <strong class="jxr_keyword">if</strong> (result == 0) { <em class="jxr_comment">// arity is same</em>
<a class="jxr_linenumber" name="L3882" href="#L3882">3882</a> <strong class="jxr_keyword">if</strong> (isMultiValue(f1) &amp;&amp; !isMultiValue(f2)) { result = 1; } <em class="jxr_comment">// f1 &gt; f2</em>
<a class="jxr_linenumber" name="L3883" href="#L3883">3883</a> <strong class="jxr_keyword">if</strong> (!isMultiValue(f1) &amp;&amp; isMultiValue(f2)) { result = -1; } <em class="jxr_comment">// f1 &lt; f2</em>
<a class="jxr_linenumber" name="L3884" href="#L3884">3884</a> }
<a class="jxr_linenumber" name="L3885" href="#L3885">3885</a> <strong class="jxr_keyword">return</strong> result == 0 ? <strong class="jxr_keyword">super</strong>.compare(f1, f2) : result;
<a class="jxr_linenumber" name="L3886" href="#L3886">3886</a> }
<a class="jxr_linenumber" name="L3887" href="#L3887">3887</a> }
<a class="jxr_linenumber" name="L3888" href="#L3888">3888</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3889" href="#L3889">3889</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Responsible for spacing out {@link Text} values according to the {@link Column} definitions the table was</em>
<a class="jxr_linenumber" name="L3890" href="#L3890">3890</a> <em class="jxr_javadoccomment"> * created with. Columns have a width, indentation, and an overflow policy that decides what to do if a value is</em>
<a class="jxr_linenumber" name="L3891" href="#L3891">3891</a> <em class="jxr_javadoccomment"> * longer than the column's width.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L3892" href="#L3892">3892</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3893" href="#L3893">3893</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a> {
<a class="jxr_linenumber" name="L3894" href="#L3894">3894</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3895" href="#L3895">3895</a> <em class="jxr_javadoccomment"> * Helper class to index positions in a {@code Help.TextTable}.</em>
<a class="jxr_linenumber" name="L3896" href="#L3896">3896</a> <em class="jxr_javadoccomment"> * @since 2.0</em>
<a class="jxr_linenumber" name="L3897" href="#L3897">3897</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3898" href="#L3898">3898</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Cell</a> {
<a class="jxr_linenumber" name="L3899" href="#L3899">3899</a> <em class="jxr_javadoccomment">/** Table column index (zero based). */</em>
<a class="jxr_linenumber" name="L3900" href="#L3900">3900</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> column;
<a class="jxr_linenumber" name="L3901" href="#L3901">3901</a> <em class="jxr_javadoccomment">/** Table row index (zero based). */</em>
<a class="jxr_linenumber" name="L3902" href="#L3902">3902</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> row;
<a class="jxr_linenumber" name="L3903" href="#L3903">3903</a> <em class="jxr_javadoccomment">/** Constructs a new Cell with the specified coordinates in the table.</em>
<a class="jxr_linenumber" name="L3904" href="#L3904">3904</a> <em class="jxr_javadoccomment"> * @param column the zero-based table column</em>
<a class="jxr_linenumber" name="L3905" href="#L3905">3905</a> <em class="jxr_javadoccomment"> * @param row the zero-based table row */</em>
<a class="jxr_linenumber" name="L3906" href="#L3906">3906</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Cell</a>(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> column, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> row) { <strong class="jxr_keyword">this</strong>.column = column; <strong class="jxr_keyword">this</strong>.row = row; }
<a class="jxr_linenumber" name="L3907" href="#L3907">3907</a> }
<a class="jxr_linenumber" name="L3908" href="#L3908">3908</a>
<a class="jxr_linenumber" name="L3909" href="#L3909">3909</a> <em class="jxr_javadoccomment">/** The column definitions of this table. */</em>
<a class="jxr_linenumber" name="L3910" href="#L3910">3910</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>[] columns;
<a class="jxr_linenumber" name="L3911" href="#L3911">3911</a>
<a class="jxr_linenumber" name="L3912" href="#L3912">3912</a> <em class="jxr_javadoccomment">/** The {@code char[]} slots of the {@code TextTable} to copy text values into. */</em>
<a class="jxr_linenumber" name="L3913" href="#L3913">3913</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> List&lt;Text&gt; columnValues = <strong class="jxr_keyword">new</strong> ArrayList&lt;Text&gt;();
<a class="jxr_linenumber" name="L3914" href="#L3914">3914</a>
<a class="jxr_linenumber" name="L3915" href="#L3915">3915</a> <em class="jxr_javadoccomment">/** By default, indent wrapped lines by 2 spaces. */</em>
<a class="jxr_linenumber" name="L3916" href="#L3916">3916</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> indentWrappedLines = 2;
<a class="jxr_linenumber" name="L3917" href="#L3917">3917</a>
<a class="jxr_linenumber" name="L3918" href="#L3918">3918</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi;
<a class="jxr_linenumber" name="L3919" href="#L3919">3919</a>
<a class="jxr_linenumber" name="L3920" href="#L3920">3920</a> <em class="jxr_javadoccomment">/** Constructs a TextTable with five columns as follows:</em>
<a class="jxr_linenumber" name="L3921" href="#L3921">3921</a> <em class="jxr_javadoccomment"> * &lt;ol&gt;</em>
<a class="jxr_linenumber" name="L3922" href="#L3922">3922</a> <em class="jxr_javadoccomment"> * &lt;li&gt;required option/parameter marker (width: 2, indent: 0, TRUNCATE on overflow)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3923" href="#L3923">3923</a> <em class="jxr_javadoccomment"> * &lt;li&gt;short option name (width: 2, indent: 0, TRUNCATE on overflow)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3924" href="#L3924">3924</a> <em class="jxr_javadoccomment"> * &lt;li&gt;comma separator (width: 1, indent: 0, TRUNCATE on overflow)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3925" href="#L3925">3925</a> <em class="jxr_javadoccomment"> * &lt;li&gt;long option name(s) (width: 24, indent: 1, SPAN multiple columns on overflow)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3926" href="#L3926">3926</a> <em class="jxr_javadoccomment"> * &lt;li&gt;description line(s) (width: 51, indent: 1, WRAP to next row on overflow)&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L3927" href="#L3927">3927</a> <em class="jxr_javadoccomment"> * &lt;/ol&gt;</em>
<a class="jxr_linenumber" name="L3928" href="#L3928">3928</a> <em class="jxr_javadoccomment"> * @param ansi whether to emit ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L3929" href="#L3929">3929</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3930" href="#L3930">3930</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi) {
<a class="jxr_linenumber" name="L3931" href="#L3931">3931</a> <em class="jxr_comment">// "* -c, --create Creates a ...."</em>
<a class="jxr_linenumber" name="L3932" href="#L3932">3932</a> <strong class="jxr_keyword">this</strong>(ansi, <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>[] {
<a class="jxr_linenumber" name="L3933" href="#L3933">3933</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>(2, 0, TRUNCATE), <em class="jxr_comment">// "*"</em>
<a class="jxr_linenumber" name="L3934" href="#L3934">3934</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>(2, 0, TRUNCATE), <em class="jxr_comment">// "-c"</em>
<a class="jxr_linenumber" name="L3935" href="#L3935">3935</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>(1, 0, TRUNCATE), <em class="jxr_comment">// ","</em>
<a class="jxr_linenumber" name="L3936" href="#L3936">3936</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>(optionsColumnWidth - 2 - 2 - 1 , 1, SPAN), <em class="jxr_comment">// " --create"</em>
<a class="jxr_linenumber" name="L3937" href="#L3937">3937</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>(usageHelpWidth - optionsColumnWidth, 1, WRAP) <em class="jxr_comment">// " Creates a ..."</em>
<a class="jxr_linenumber" name="L3938" href="#L3938">3938</a> });
<a class="jxr_linenumber" name="L3939" href="#L3939">3939</a> }
<a class="jxr_linenumber" name="L3940" href="#L3940">3940</a>
<a class="jxr_linenumber" name="L3941" href="#L3941">3941</a> <em class="jxr_javadoccomment">/** Constructs a new TextTable with columns with the specified width, all SPANning multiple columns on</em>
<a class="jxr_linenumber" name="L3942" href="#L3942">3942</a> <em class="jxr_javadoccomment"> * overflow except the last column which WRAPS to the next row.</em>
<a class="jxr_linenumber" name="L3943" href="#L3943">3943</a> <em class="jxr_javadoccomment"> * @param ansi whether to emit ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L3944" href="#L3944">3944</a> <em class="jxr_javadoccomment"> * @param columnWidths the width of the table columns (all columns have zero indent)</em>
<a class="jxr_linenumber" name="L3945" href="#L3945">3945</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L3946" href="#L3946">3946</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong>... columnWidths) {
<a class="jxr_linenumber" name="L3947" href="#L3947">3947</a> <strong class="jxr_keyword">this</strong>.ansi = Assert.notNull(ansi, <span class="jxr_string">"ansi"</span>);
<a class="jxr_linenumber" name="L3948" href="#L3948">3948</a> columns = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>[columnWidths.length];
<a class="jxr_linenumber" name="L3949" href="#L3949">3949</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; columnWidths.length; i++) {
<a class="jxr_linenumber" name="L3950" href="#L3950">3950</a> columns[i] = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>(columnWidths[i], 0, i == columnWidths.length - 1 ? SPAN: WRAP);
<a class="jxr_linenumber" name="L3951" href="#L3951">3951</a> }
<a class="jxr_linenumber" name="L3952" href="#L3952">3952</a> }
<a class="jxr_linenumber" name="L3953" href="#L3953">3953</a> <em class="jxr_javadoccomment">/** Constructs a {@code TextTable} with the specified columns.</em>
<a class="jxr_linenumber" name="L3954" href="#L3954">3954</a> <em class="jxr_javadoccomment"> * @param ansi whether to emit ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L3955" href="#L3955">3955</a> <em class="jxr_javadoccomment"> * @param columns columns to construct this TextTable with */</em>
<a class="jxr_linenumber" name="L3956" href="#L3956">3956</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TextTable</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi, <strong class="jxr_keyword">final</strong> Column... columns) {
<a class="jxr_linenumber" name="L3957" href="#L3957">3957</a> <strong class="jxr_keyword">this</strong>.ansi = Assert.notNull(ansi, <span class="jxr_string">"ansi"</span>);
<a class="jxr_linenumber" name="L3958" href="#L3958">3958</a> <strong class="jxr_keyword">this</strong>.columns = Assert.notNull(columns, <span class="jxr_string">"columns"</span>);
<a class="jxr_linenumber" name="L3959" href="#L3959">3959</a> <strong class="jxr_keyword">if</strong> (columns.length == 0) { <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalArgumentException(<span class="jxr_string">"At least one column is required"</span>); }
<a class="jxr_linenumber" name="L3960" href="#L3960">3960</a> }
<a class="jxr_linenumber" name="L3961" href="#L3961">3961</a> <em class="jxr_javadoccomment">/** Returns the {@code Text} slot at the specified row and column to write a text value into.</em>
<a class="jxr_linenumber" name="L3962" href="#L3962">3962</a> <em class="jxr_javadoccomment"> * @param row the row of the cell whose Text to return</em>
<a class="jxr_linenumber" name="L3963" href="#L3963">3963</a> <em class="jxr_javadoccomment"> * @param col the column of the cell whose Text to return</em>
<a class="jxr_linenumber" name="L3964" href="#L3964">3964</a> <em class="jxr_javadoccomment"> * @return the Text object at the specified row and column</em>
<a class="jxr_linenumber" name="L3965" href="#L3965">3965</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L3966" href="#L3966">3966</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> textAt(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> row, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> col) { <strong class="jxr_keyword">return</strong> columnValues.get(col + (row * columns.length)); }
<a class="jxr_linenumber" name="L3967" href="#L3967">3967</a>
<a class="jxr_linenumber" name="L3968" href="#L3968">3968</a> <em class="jxr_javadoccomment">/** Returns the {@code Text} slot at the specified row and column to write a text value into.</em>
<a class="jxr_linenumber" name="L3969" href="#L3969">3969</a> <em class="jxr_javadoccomment"> * @param row the row of the cell whose Text to return</em>
<a class="jxr_linenumber" name="L3970" href="#L3970">3970</a> <em class="jxr_javadoccomment"> * @param col the column of the cell whose Text to return</em>
<a class="jxr_linenumber" name="L3971" href="#L3971">3971</a> <em class="jxr_javadoccomment"> * @return the Text object at the specified row and column</em>
<a class="jxr_linenumber" name="L3972" href="#L3972">3972</a> <em class="jxr_javadoccomment"> * @deprecated use {@link #textAt(int, int)} instead */</em>
<a class="jxr_linenumber" name="L3973" href="#L3973">3973</a> @Deprecated
<a class="jxr_linenumber" name="L3974" href="#L3974">3974</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> cellAt(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> row, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> col) { <strong class="jxr_keyword">return</strong> textAt(row, col); }
<a class="jxr_linenumber" name="L3975" href="#L3975">3975</a>
<a class="jxr_linenumber" name="L3976" href="#L3976">3976</a> <em class="jxr_javadoccomment">/** Returns the current number of rows of this {@code TextTable}.</em>
<a class="jxr_linenumber" name="L3977" href="#L3977">3977</a> <em class="jxr_javadoccomment"> * @return the current number of rows in this TextTable */</em>
<a class="jxr_linenumber" name="L3978" href="#L3978">3978</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> rowCount() { <strong class="jxr_keyword">return</strong> columnValues.size() / columns.length; }
<a class="jxr_linenumber" name="L3979" href="#L3979">3979</a>
<a class="jxr_linenumber" name="L3980" href="#L3980">3980</a> <em class="jxr_javadoccomment">/** Adds the required {@code char[]} slots for a new row to the {@link #columnValues} field. */</em>
<a class="jxr_linenumber" name="L3981" href="#L3981">3981</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> addEmptyRow() {
<a class="jxr_linenumber" name="L3982" href="#L3982">3982</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; columns.length; i++) {
<a class="jxr_linenumber" name="L3983" href="#L3983">3983</a> columnValues.add(ansi.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(columns[i].width));
<a class="jxr_linenumber" name="L3984" href="#L3984">3984</a> }
<a class="jxr_linenumber" name="L3985" href="#L3985">3985</a> }
<a class="jxr_linenumber" name="L3986" href="#L3986">3986</a>
<a class="jxr_linenumber" name="L3987" href="#L3987">3987</a> <em class="jxr_javadoccomment">/** Delegates to {@link #addRowValues(CommandLine.Help.Ansi.Text...)}.</em>
<a class="jxr_linenumber" name="L3988" href="#L3988">3988</a> <em class="jxr_javadoccomment"> * @param values the text values to display in each column of the current row */</em>
<a class="jxr_linenumber" name="L3989" href="#L3989">3989</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> addRowValues(<strong class="jxr_keyword">final</strong> String... values) {
<a class="jxr_linenumber" name="L3990" href="#L3990">3990</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] array = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[values.length];
<a class="jxr_linenumber" name="L3991" href="#L3991">3991</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; array.length; i++) {
<a class="jxr_linenumber" name="L3992" href="#L3992">3992</a> array[i] = values[i] == <strong class="jxr_keyword">null</strong> ? Ansi.EMPTY_TEXT : ansi.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(values[i]);
<a class="jxr_linenumber" name="L3993" href="#L3993">3993</a> }
<a class="jxr_linenumber" name="L3994" href="#L3994">3994</a> addRowValues(array);
<a class="jxr_linenumber" name="L3995" href="#L3995">3995</a> }
<a class="jxr_linenumber" name="L3996" href="#L3996">3996</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L3997" href="#L3997">3997</a> <em class="jxr_javadoccomment"> * Adds a new {@linkplain TextTable#addEmptyRow() empty row}, then calls {@link</em>
<a class="jxr_linenumber" name="L3998" href="#L3998">3998</a> <em class="jxr_javadoccomment"> * TextTable#putValue(int, int, CommandLine.Help.Ansi.Text) putValue} for each of the specified values, adding more empty rows</em>
<a class="jxr_linenumber" name="L3999" href="#L3999">3999</a> <em class="jxr_javadoccomment"> * if the return value indicates that the value spanned multiple columns or was wrapped to multiple rows.</em>
<a class="jxr_linenumber" name="L4000" href="#L4000">4000</a> <em class="jxr_javadoccomment"> * @param values the values to write into a new row in this TextTable</em>
<a class="jxr_linenumber" name="L4001" href="#L4001">4001</a> <em class="jxr_javadoccomment"> * @throws IllegalArgumentException if the number of values exceeds the number of Columns in this table</em>
<a class="jxr_linenumber" name="L4002" href="#L4002">4002</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4003" href="#L4003">4003</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> addRowValues(<strong class="jxr_keyword">final</strong> Text... values) {
<a class="jxr_linenumber" name="L4004" href="#L4004">4004</a> <strong class="jxr_keyword">if</strong> (values.length &gt; columns.length) {
<a class="jxr_linenumber" name="L4005" href="#L4005">4005</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalArgumentException(values.length + <span class="jxr_string">" values don't fit in "</span> +
<a class="jxr_linenumber" name="L4006" href="#L4006">4006</a> columns.length + <span class="jxr_string">" columns"</span>);
<a class="jxr_linenumber" name="L4007" href="#L4007">4007</a> }
<a class="jxr_linenumber" name="L4008" href="#L4008">4008</a> addEmptyRow();
<a class="jxr_linenumber" name="L4009" href="#L4009">4009</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> col = 0; col &lt; values.length; col++) {
<a class="jxr_linenumber" name="L4010" href="#L4010">4010</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> row = rowCount() - 1;<em class="jxr_comment">// write to last row: previous value may have wrapped to next row</em>
<a class="jxr_linenumber" name="L4011" href="#L4011">4011</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Cell</a> cell = putValue(row, col, values[col]);
<a class="jxr_linenumber" name="L4012" href="#L4012">4012</a>
<a class="jxr_linenumber" name="L4013" href="#L4013">4013</a> <em class="jxr_comment">// add row if a value spanned/wrapped and there are still remaining values</em>
<a class="jxr_linenumber" name="L4014" href="#L4014">4014</a> <strong class="jxr_keyword">if</strong> ((cell.row != row || cell.column != col) &amp;&amp; col != values.length - 1) {
<a class="jxr_linenumber" name="L4015" href="#L4015">4015</a> addEmptyRow();
<a class="jxr_linenumber" name="L4016" href="#L4016">4016</a> }
<a class="jxr_linenumber" name="L4017" href="#L4017">4017</a> }
<a class="jxr_linenumber" name="L4018" href="#L4018">4018</a> }
<a class="jxr_linenumber" name="L4019" href="#L4019">4019</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4020" href="#L4020">4020</a> <em class="jxr_javadoccomment"> * Writes the specified value into the cell at the specified row and column and returns the last row and</em>
<a class="jxr_linenumber" name="L4021" href="#L4021">4021</a> <em class="jxr_javadoccomment"> * column written to. Depending on the Column's {@link Column#overflow Overflow} policy, the value may span</em>
<a class="jxr_linenumber" name="L4022" href="#L4022">4022</a> <em class="jxr_javadoccomment"> * multiple columns or wrap to multiple rows when larger than the column width.</em>
<a class="jxr_linenumber" name="L4023" href="#L4023">4023</a> <em class="jxr_javadoccomment"> * @param row the target row in the table</em>
<a class="jxr_linenumber" name="L4024" href="#L4024">4024</a> <em class="jxr_javadoccomment"> * @param col the target column in the table to write to</em>
<a class="jxr_linenumber" name="L4025" href="#L4025">4025</a> <em class="jxr_javadoccomment"> * @param value the value to write</em>
<a class="jxr_linenumber" name="L4026" href="#L4026">4026</a> <em class="jxr_javadoccomment"> * @return a Cell indicating the position in the table that was last written to (since 2.0)</em>
<a class="jxr_linenumber" name="L4027" href="#L4027">4027</a> <em class="jxr_javadoccomment"> * @throws IllegalArgumentException if the specified row exceeds the table's {@linkplain</em>
<a class="jxr_linenumber" name="L4028" href="#L4028">4028</a> <em class="jxr_javadoccomment"> * TextTable#rowCount() row count}</em>
<a class="jxr_linenumber" name="L4029" href="#L4029">4029</a> <em class="jxr_javadoccomment"> * @since 2.0 (previous versions returned a {@code java.awt.Point} object)</em>
<a class="jxr_linenumber" name="L4030" href="#L4030">4030</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4031" href="#L4031">4031</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Cell</a> putValue(<strong class="jxr_keyword">int</strong> row, <strong class="jxr_keyword">int</strong> col, <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> value) {
<a class="jxr_linenumber" name="L4032" href="#L4032">4032</a> <strong class="jxr_keyword">if</strong> (row &gt; rowCount() - 1) {
<a class="jxr_linenumber" name="L4033" href="#L4033">4033</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalArgumentException(<span class="jxr_string">"Cannot write to row "</span> + row + <span class="jxr_string">": rowCount="</span> + rowCount());
<a class="jxr_linenumber" name="L4034" href="#L4034">4034</a> }
<a class="jxr_linenumber" name="L4035" href="#L4035">4035</a> <strong class="jxr_keyword">if</strong> (value == <strong class="jxr_keyword">null</strong> || value.plain.length() == 0) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Cell(col, row); }
<a class="jxr_linenumber" name="L4036" href="#L4036">4036</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a> column = columns[col];
<a class="jxr_linenumber" name="L4037" href="#L4037">4037</a> <strong class="jxr_keyword">int</strong> indent = column.indent;
<a class="jxr_linenumber" name="L4038" href="#L4038">4038</a> <strong class="jxr_keyword">switch</strong> (column.overflow) {
<a class="jxr_linenumber" name="L4039" href="#L4039">4039</a> <strong class="jxr_keyword">case</strong> TRUNCATE:
<a class="jxr_linenumber" name="L4040" href="#L4040">4040</a> copy(value, textAt(row, col), indent);
<a class="jxr_linenumber" name="L4041" href="#L4041">4041</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Cell</a>(col, row);
<a class="jxr_linenumber" name="L4042" href="#L4042">4042</a> <strong class="jxr_keyword">case</strong> SPAN:
<a class="jxr_linenumber" name="L4043" href="#L4043">4043</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> startColumn = col;
<a class="jxr_linenumber" name="L4044" href="#L4044">4044</a> <strong class="jxr_keyword">do</strong> {
<a class="jxr_linenumber" name="L4045" href="#L4045">4045</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> lastColumn = col == columns.length - 1;
<a class="jxr_linenumber" name="L4046" href="#L4046">4046</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> charsWritten = lastColumn
<a class="jxr_linenumber" name="L4047" href="#L4047">4047</a> ? copy(BreakIterator.getLineInstance(), value, textAt(row, col), indent)
<a class="jxr_linenumber" name="L4048" href="#L4048">4048</a> : copy(value, textAt(row, col), indent);
<a class="jxr_linenumber" name="L4049" href="#L4049">4049</a> value = value.substring(charsWritten);
<a class="jxr_linenumber" name="L4050" href="#L4050">4050</a> indent = 0;
<a class="jxr_linenumber" name="L4051" href="#L4051">4051</a> <strong class="jxr_keyword">if</strong> (value.length &gt; 0) { <em class="jxr_comment">// value did not fit in column</em>
<a class="jxr_linenumber" name="L4052" href="#L4052">4052</a> ++col; <em class="jxr_comment">// write remainder of value in next column</em>
<a class="jxr_linenumber" name="L4053" href="#L4053">4053</a> }
<a class="jxr_linenumber" name="L4054" href="#L4054">4054</a> <strong class="jxr_keyword">if</strong> (value.length &gt; 0 &amp;&amp; col &gt;= columns.length) { <em class="jxr_comment">// we filled up all columns on this row</em>
<a class="jxr_linenumber" name="L4055" href="#L4055">4055</a> addEmptyRow();
<a class="jxr_linenumber" name="L4056" href="#L4056">4056</a> row++;
<a class="jxr_linenumber" name="L4057" href="#L4057">4057</a> col = startColumn;
<a class="jxr_linenumber" name="L4058" href="#L4058">4058</a> indent = column.indent + indentWrappedLines;
<a class="jxr_linenumber" name="L4059" href="#L4059">4059</a> }
<a class="jxr_linenumber" name="L4060" href="#L4060">4060</a> } <strong class="jxr_keyword">while</strong> (value.length &gt; 0);
<a class="jxr_linenumber" name="L4061" href="#L4061">4061</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Cell</a>(col, row);
<a class="jxr_linenumber" name="L4062" href="#L4062">4062</a> <strong class="jxr_keyword">case</strong> WRAP:
<a class="jxr_linenumber" name="L4063" href="#L4063">4063</a> <strong class="jxr_keyword">final</strong> BreakIterator lineBreakIterator = BreakIterator.getLineInstance();
<a class="jxr_linenumber" name="L4064" href="#L4064">4064</a> <strong class="jxr_keyword">do</strong> {
<a class="jxr_linenumber" name="L4065" href="#L4065">4065</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> charsWritten = copy(lineBreakIterator, value, textAt(row, col), indent);
<a class="jxr_linenumber" name="L4066" href="#L4066">4066</a> value = value.substring(charsWritten);
<a class="jxr_linenumber" name="L4067" href="#L4067">4067</a> indent = column.indent + indentWrappedLines;
<a class="jxr_linenumber" name="L4068" href="#L4068">4068</a> <strong class="jxr_keyword">if</strong> (value.length &gt; 0) { <em class="jxr_comment">// value did not fit in column</em>
<a class="jxr_linenumber" name="L4069" href="#L4069">4069</a> ++row; <em class="jxr_comment">// write remainder of value in next row</em>
<a class="jxr_linenumber" name="L4070" href="#L4070">4070</a> addEmptyRow();
<a class="jxr_linenumber" name="L4071" href="#L4071">4071</a> }
<a class="jxr_linenumber" name="L4072" href="#L4072">4072</a> } <strong class="jxr_keyword">while</strong> (value.length &gt; 0);
<a class="jxr_linenumber" name="L4073" href="#L4073">4073</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Cell</a>(col, row);
<a class="jxr_linenumber" name="L4074" href="#L4074">4074</a> }
<a class="jxr_linenumber" name="L4075" href="#L4075">4075</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException(column.overflow.toString());
<a class="jxr_linenumber" name="L4076" href="#L4076">4076</a> }
<a class="jxr_linenumber" name="L4077" href="#L4077">4077</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> length(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> str) {
<a class="jxr_linenumber" name="L4078" href="#L4078">4078</a> <strong class="jxr_keyword">return</strong> str.length; <em class="jxr_comment">// TODO count some characters as double length</em>
<a class="jxr_linenumber" name="L4079" href="#L4079">4079</a> }
<a class="jxr_linenumber" name="L4080" href="#L4080">4080</a>
<a class="jxr_linenumber" name="L4081" href="#L4081">4081</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> copy(<strong class="jxr_keyword">final</strong> BreakIterator line, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> text, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> columnValue, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> offset) {
<a class="jxr_linenumber" name="L4082" href="#L4082">4082</a> <em class="jxr_comment">// Deceive the BreakIterator to ensure no line breaks after '-' character</em>
<a class="jxr_linenumber" name="L4083" href="#L4083">4083</a> line.setText(text.plainString().replace(<span class="jxr_string">"-"</span>, <span class="jxr_string">"\u00ff"</span>));
<a class="jxr_linenumber" name="L4084" href="#L4084">4084</a> <strong class="jxr_keyword">int</strong> done = 0;
<a class="jxr_linenumber" name="L4085" href="#L4085">4085</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> start = line.first(), end = line.next(); end != BreakIterator.DONE; start = end, end = line.next()) {
<a class="jxr_linenumber" name="L4086" href="#L4086">4086</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> word = text.substring(start, end); <em class="jxr_comment">//.replace("\u00ff", "-"); // not needed</em>
<a class="jxr_linenumber" name="L4087" href="#L4087">4087</a> <strong class="jxr_keyword">if</strong> (columnValue.maxLength &gt;= offset + done + length(word)) {
<a class="jxr_linenumber" name="L4088" href="#L4088">4088</a> done += copy(word, columnValue, offset + done); <em class="jxr_comment">// TODO localized length</em>
<a class="jxr_linenumber" name="L4089" href="#L4089">4089</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L4090" href="#L4090">4090</a> <strong class="jxr_keyword">break</strong>;
<a class="jxr_linenumber" name="L4091" href="#L4091">4091</a> }
<a class="jxr_linenumber" name="L4092" href="#L4092">4092</a> }
<a class="jxr_linenumber" name="L4093" href="#L4093">4093</a> <strong class="jxr_keyword">if</strong> (done == 0 &amp;&amp; length(text) &gt; columnValue.maxLength) {
<a class="jxr_linenumber" name="L4094" href="#L4094">4094</a> <em class="jxr_comment">// The value is a single word that is too big to be written to the column. Write as much as we can.</em>
<a class="jxr_linenumber" name="L4095" href="#L4095">4095</a> done = copy(text, columnValue, offset);
<a class="jxr_linenumber" name="L4096" href="#L4096">4096</a> }
<a class="jxr_linenumber" name="L4097" href="#L4097">4097</a> <strong class="jxr_keyword">return</strong> done;
<a class="jxr_linenumber" name="L4098" href="#L4098">4098</a> }
<a class="jxr_linenumber" name="L4099" href="#L4099">4099</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> copy(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> value, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> destination, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> offset) {
<a class="jxr_linenumber" name="L4100" href="#L4100">4100</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length = Math.min(value.length, destination.maxLength - offset);
<a class="jxr_linenumber" name="L4101" href="#L4101">4101</a> value.getStyledChars(value.from, length, destination, offset);
<a class="jxr_linenumber" name="L4102" href="#L4102">4102</a> <strong class="jxr_keyword">return</strong> length;
<a class="jxr_linenumber" name="L4103" href="#L4103">4103</a> }
<a class="jxr_linenumber" name="L4104" href="#L4104">4104</a>
<a class="jxr_linenumber" name="L4105" href="#L4105">4105</a> <em class="jxr_javadoccomment">/** Copies the text representation that we built up from the options into the specified StringBuilder.</em>
<a class="jxr_linenumber" name="L4106" href="#L4106">4106</a> <em class="jxr_javadoccomment"> * @param text the StringBuilder to write into</em>
<a class="jxr_linenumber" name="L4107" href="#L4107">4107</a> <em class="jxr_javadoccomment"> * @return the specified StringBuilder object (to allow method chaining and a more fluid API) */</em>
<a class="jxr_linenumber" name="L4108" href="#L4108">4108</a> <strong class="jxr_keyword">public</strong> StringBuilder toString(<strong class="jxr_keyword">final</strong> StringBuilder text) {
<a class="jxr_linenumber" name="L4109" href="#L4109">4109</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> columnCount = <strong class="jxr_keyword">this</strong>.columns.length;
<a class="jxr_linenumber" name="L4110" href="#L4110">4110</a> <strong class="jxr_keyword">final</strong> StringBuilder row = <strong class="jxr_keyword">new</strong> StringBuilder(usageHelpWidth);
<a class="jxr_linenumber" name="L4111" href="#L4111">4111</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; columnValues.size(); i++) {
<a class="jxr_linenumber" name="L4112" href="#L4112">4112</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> column = columnValues.get(i);
<a class="jxr_linenumber" name="L4113" href="#L4113">4113</a> row.append(column.toString());
<a class="jxr_linenumber" name="L4114" href="#L4114">4114</a> row.append(<strong class="jxr_keyword">new</strong> String(spaces(columns[i % columnCount].width - column.length)));
<a class="jxr_linenumber" name="L4115" href="#L4115">4115</a> <strong class="jxr_keyword">if</strong> (i % columnCount == columnCount - 1) {
<a class="jxr_linenumber" name="L4116" href="#L4116">4116</a> <strong class="jxr_keyword">int</strong> lastChar = row.length() - 1;
<a class="jxr_linenumber" name="L4117" href="#L4117">4117</a> <strong class="jxr_keyword">while</strong> (lastChar &gt;= 0 &amp;&amp; row.charAt(lastChar) == ' ') {lastChar--;} <em class="jxr_comment">// rtrim</em>
<a class="jxr_linenumber" name="L4118" href="#L4118">4118</a> row.setLength(lastChar + 1);
<a class="jxr_linenumber" name="L4119" href="#L4119">4119</a> text.append(row.toString()).append(System.getProperty(<span class="jxr_string">"line.separator"</span>));
<a class="jxr_linenumber" name="L4120" href="#L4120">4120</a> row.setLength(0);
<a class="jxr_linenumber" name="L4121" href="#L4121">4121</a> }
<a class="jxr_linenumber" name="L4122" href="#L4122">4122</a> }
<a class="jxr_linenumber" name="L4123" href="#L4123">4123</a> <em class="jxr_comment">//if (Ansi.enabled()) { text.append(Style.reset.off()); }</em>
<a class="jxr_linenumber" name="L4124" href="#L4124">4124</a> <strong class="jxr_keyword">return</strong> text;
<a class="jxr_linenumber" name="L4125" href="#L4125">4125</a> }
<a class="jxr_linenumber" name="L4126" href="#L4126">4126</a> @Override
<a class="jxr_linenumber" name="L4127" href="#L4127">4127</a> <strong class="jxr_keyword">public</strong> String toString() { <strong class="jxr_keyword">return</strong> toString(<strong class="jxr_keyword">new</strong> StringBuilder()).toString(); }
<a class="jxr_linenumber" name="L4128" href="#L4128">4128</a> }
<a class="jxr_linenumber" name="L4129" href="#L4129">4129</a> <em class="jxr_javadoccomment">/** Columns define the width, indent (leading number of spaces in a column before the value) and</em>
<a class="jxr_linenumber" name="L4130" href="#L4130">4130</a> <em class="jxr_javadoccomment"> * {@linkplain Overflow Overflow} policy of a column in a {@linkplain TextTable TextTable}. */</em>
<a class="jxr_linenumber" name="L4131" href="#L4131">4131</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a> {
<a class="jxr_linenumber" name="L4132" href="#L4132">4132</a>
<a class="jxr_linenumber" name="L4133" href="#L4133">4133</a> <em class="jxr_javadoccomment">/** Policy for handling text that is longer than the column width:</em>
<a class="jxr_linenumber" name="L4134" href="#L4134">4134</a> <em class="jxr_javadoccomment"> * span multiple columns, wrap to the next row, or simply truncate the portion that doesn't fit. */</em>
<a class="jxr_linenumber" name="L4135" href="#L4135">4135</a> <strong class="jxr_keyword">public</strong> enum <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Overflow</a> { TRUNCATE, SPAN, WRAP }
<a class="jxr_linenumber" name="L4136" href="#L4136">4136</a>
<a class="jxr_linenumber" name="L4137" href="#L4137">4137</a> <em class="jxr_javadoccomment">/** Column width in characters */</em>
<a class="jxr_linenumber" name="L4138" href="#L4138">4138</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> width;
<a class="jxr_linenumber" name="L4139" href="#L4139">4139</a>
<a class="jxr_linenumber" name="L4140" href="#L4140">4140</a> <em class="jxr_javadoccomment">/** Indent (number of empty spaces at the start of the column preceding the text value) */</em>
<a class="jxr_linenumber" name="L4141" href="#L4141">4141</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> indent;
<a class="jxr_linenumber" name="L4142" href="#L4142">4142</a>
<a class="jxr_linenumber" name="L4143" href="#L4143">4143</a> <em class="jxr_javadoccomment">/** Policy that determines how to handle values larger than the column width. */</em>
<a class="jxr_linenumber" name="L4144" href="#L4144">4144</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Overflow</a> overflow;
<a class="jxr_linenumber" name="L4145" href="#L4145">4145</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Column</a>(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> width, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> indent, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Overflow</a> overflow) {
<a class="jxr_linenumber" name="L4146" href="#L4146">4146</a> <strong class="jxr_keyword">this</strong>.width = width;
<a class="jxr_linenumber" name="L4147" href="#L4147">4147</a> <strong class="jxr_keyword">this</strong>.indent = indent;
<a class="jxr_linenumber" name="L4148" href="#L4148">4148</a> <strong class="jxr_keyword">this</strong>.overflow = Assert.notNull(overflow, <span class="jxr_string">"overflow"</span>);
<a class="jxr_linenumber" name="L4149" href="#L4149">4149</a> }
<a class="jxr_linenumber" name="L4150" href="#L4150">4150</a> }
<a class="jxr_linenumber" name="L4151" href="#L4151">4151</a>
<a class="jxr_linenumber" name="L4152" href="#L4152">4152</a> <em class="jxr_javadoccomment">/** All usage help message are generated with a color scheme that assigns certain styles and colors to common</em>
<a class="jxr_linenumber" name="L4153" href="#L4153">4153</a> <em class="jxr_javadoccomment"> * parts of a usage message: the command name, options, positional parameters and option parameters.</em>
<a class="jxr_linenumber" name="L4154" href="#L4154">4154</a> <em class="jxr_javadoccomment"> * Users may customize these styles by creating Help with a custom color scheme.</em>
<a class="jxr_linenumber" name="L4155" href="#L4155">4155</a> <em class="jxr_javadoccomment"> * &lt;p&gt;Note that these options and styles may not be rendered if ANSI escape codes are not</em>
<a class="jxr_linenumber" name="L4156" href="#L4156">4156</a> <em class="jxr_javadoccomment"> * {@linkplain Ansi#enabled() enabled}.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L4157" href="#L4157">4157</a> <em class="jxr_javadoccomment"> * @see Help#defaultColorScheme(Ansi)</em>
<a class="jxr_linenumber" name="L4158" href="#L4158">4158</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4159" href="#L4159">4159</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> {
<a class="jxr_linenumber" name="L4160" href="#L4160">4160</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; commandStyles = <strong class="jxr_keyword">new</strong> ArrayList&lt;IStyle&gt;();
<a class="jxr_linenumber" name="L4161" href="#L4161">4161</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; optionStyles = <strong class="jxr_keyword">new</strong> ArrayList&lt;IStyle&gt;();
<a class="jxr_linenumber" name="L4162" href="#L4162">4162</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; parameterStyles = <strong class="jxr_keyword">new</strong> ArrayList&lt;IStyle&gt;();
<a class="jxr_linenumber" name="L4163" href="#L4163">4163</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; optionParamStyles = <strong class="jxr_keyword">new</strong> ArrayList&lt;IStyle&gt;();
<a class="jxr_linenumber" name="L4164" href="#L4164">4164</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi;
<a class="jxr_linenumber" name="L4165" href="#L4165">4165</a>
<a class="jxr_linenumber" name="L4166" href="#L4166">4166</a> <em class="jxr_javadoccomment">/** Constructs a new ColorScheme with {@link Help.Ansi#AUTO}. */</em>
<a class="jxr_linenumber" name="L4167" href="#L4167">4167</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a>() { <strong class="jxr_keyword">this</strong>(Ansi.AUTO); }
<a class="jxr_linenumber" name="L4168" href="#L4168">4168</a>
<a class="jxr_linenumber" name="L4169" href="#L4169">4169</a> <em class="jxr_javadoccomment">/** Constructs a new ColorScheme with the specified Ansi enabled mode.</em>
<a class="jxr_linenumber" name="L4170" href="#L4170">4170</a> <em class="jxr_javadoccomment"> * @param ansi whether to emit ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L4171" href="#L4171">4171</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4172" href="#L4172">4172</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi) {<strong class="jxr_keyword">this</strong>.ansi = Assert.notNull(ansi, <span class="jxr_string">"ansi"</span>); }
<a class="jxr_linenumber" name="L4173" href="#L4173">4173</a>
<a class="jxr_linenumber" name="L4174" href="#L4174">4174</a> <em class="jxr_javadoccomment">/** Adds the specified styles to the registered styles for commands in this color scheme and returns this color scheme.</em>
<a class="jxr_linenumber" name="L4175" href="#L4175">4175</a> <em class="jxr_javadoccomment"> * @param styles the styles to add to the registered styles for commands in this color scheme</em>
<a class="jxr_linenumber" name="L4176" href="#L4176">4176</a> <em class="jxr_javadoccomment"> * @return this color scheme to enable method chaining for a more fluent API */</em>
<a class="jxr_linenumber" name="L4177" href="#L4177">4177</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> commands(<strong class="jxr_keyword">final</strong> IStyle... styles) { <strong class="jxr_keyword">return</strong> addAll(commandStyles, styles); }
<a class="jxr_linenumber" name="L4178" href="#L4178">4178</a> <em class="jxr_javadoccomment">/** Adds the specified styles to the registered styles for options in this color scheme and returns this color scheme.</em>
<a class="jxr_linenumber" name="L4179" href="#L4179">4179</a> <em class="jxr_javadoccomment"> * @param styles the styles to add to registered the styles for options in this color scheme</em>
<a class="jxr_linenumber" name="L4180" href="#L4180">4180</a> <em class="jxr_javadoccomment"> * @return this color scheme to enable method chaining for a more fluent API */</em>
<a class="jxr_linenumber" name="L4181" href="#L4181">4181</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> options(<strong class="jxr_keyword">final</strong> IStyle... styles) { <strong class="jxr_keyword">return</strong> addAll(optionStyles, styles);}
<a class="jxr_linenumber" name="L4182" href="#L4182">4182</a> <em class="jxr_javadoccomment">/** Adds the specified styles to the registered styles for positional parameters in this color scheme and returns this color scheme.</em>
<a class="jxr_linenumber" name="L4183" href="#L4183">4183</a> <em class="jxr_javadoccomment"> * @param styles the styles to add to registered the styles for parameters in this color scheme</em>
<a class="jxr_linenumber" name="L4184" href="#L4184">4184</a> <em class="jxr_javadoccomment"> * @return this color scheme to enable method chaining for a more fluent API */</em>
<a class="jxr_linenumber" name="L4185" href="#L4185">4185</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> parameters(<strong class="jxr_keyword">final</strong> IStyle... styles) { <strong class="jxr_keyword">return</strong> addAll(parameterStyles, styles);}
<a class="jxr_linenumber" name="L4186" href="#L4186">4186</a> <em class="jxr_javadoccomment">/** Adds the specified styles to the registered styles for option parameters in this color scheme and returns this color scheme.</em>
<a class="jxr_linenumber" name="L4187" href="#L4187">4187</a> <em class="jxr_javadoccomment"> * @param styles the styles to add to the registered styles for option parameters in this color scheme</em>
<a class="jxr_linenumber" name="L4188" href="#L4188">4188</a> <em class="jxr_javadoccomment"> * @return this color scheme to enable method chaining for a more fluent API */</em>
<a class="jxr_linenumber" name="L4189" href="#L4189">4189</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> optionParams(<strong class="jxr_keyword">final</strong> IStyle... styles) { <strong class="jxr_keyword">return</strong> addAll(optionParamStyles, styles);}
<a class="jxr_linenumber" name="L4190" href="#L4190">4190</a> <em class="jxr_javadoccomment">/** Returns a Text with all command styles applied to the specified command string.</em>
<a class="jxr_linenumber" name="L4191" href="#L4191">4191</a> <em class="jxr_javadoccomment"> * @param command the command string to apply the registered command styles to</em>
<a class="jxr_linenumber" name="L4192" href="#L4192">4192</a> <em class="jxr_javadoccomment"> * @return a Text with all command styles applied to the specified command string */</em>
<a class="jxr_linenumber" name="L4193" href="#L4193">4193</a> <strong class="jxr_keyword">public</strong> Ansi.Text commandText(<strong class="jxr_keyword">final</strong> String command) { <strong class="jxr_keyword">return</strong> ansi().apply(command, commandStyles); }
<a class="jxr_linenumber" name="L4194" href="#L4194">4194</a> <em class="jxr_javadoccomment">/** Returns a Text with all option styles applied to the specified option string.</em>
<a class="jxr_linenumber" name="L4195" href="#L4195">4195</a> <em class="jxr_javadoccomment"> * @param option the option string to apply the registered option styles to</em>
<a class="jxr_linenumber" name="L4196" href="#L4196">4196</a> <em class="jxr_javadoccomment"> * @return a Text with all option styles applied to the specified option string */</em>
<a class="jxr_linenumber" name="L4197" href="#L4197">4197</a> <strong class="jxr_keyword">public</strong> Ansi.Text optionText(<strong class="jxr_keyword">final</strong> String option) { <strong class="jxr_keyword">return</strong> ansi().apply(option, optionStyles); }
<a class="jxr_linenumber" name="L4198" href="#L4198">4198</a> <em class="jxr_javadoccomment">/** Returns a Text with all parameter styles applied to the specified parameter string.</em>
<a class="jxr_linenumber" name="L4199" href="#L4199">4199</a> <em class="jxr_javadoccomment"> * @param parameter the parameter string to apply the registered parameter styles to</em>
<a class="jxr_linenumber" name="L4200" href="#L4200">4200</a> <em class="jxr_javadoccomment"> * @return a Text with all parameter styles applied to the specified parameter string */</em>
<a class="jxr_linenumber" name="L4201" href="#L4201">4201</a> <strong class="jxr_keyword">public</strong> Ansi.Text parameterText(<strong class="jxr_keyword">final</strong> String parameter) { <strong class="jxr_keyword">return</strong> ansi().apply(parameter, parameterStyles); }
<a class="jxr_linenumber" name="L4202" href="#L4202">4202</a> <em class="jxr_javadoccomment">/** Returns a Text with all optionParam styles applied to the specified optionParam string.</em>
<a class="jxr_linenumber" name="L4203" href="#L4203">4203</a> <em class="jxr_javadoccomment"> * @param optionParam the option parameter string to apply the registered option parameter styles to</em>
<a class="jxr_linenumber" name="L4204" href="#L4204">4204</a> <em class="jxr_javadoccomment"> * @return a Text with all option parameter styles applied to the specified option parameter string */</em>
<a class="jxr_linenumber" name="L4205" href="#L4205">4205</a> <strong class="jxr_keyword">public</strong> Ansi.Text optionParamText(<strong class="jxr_keyword">final</strong> String optionParam) { <strong class="jxr_keyword">return</strong> ansi().apply(optionParam, optionParamStyles); }
<a class="jxr_linenumber" name="L4206" href="#L4206">4206</a>
<a class="jxr_linenumber" name="L4207" href="#L4207">4207</a> <em class="jxr_javadoccomment">/** Replaces colors and styles in this scheme with ones specified in system properties, and returns this scheme.</em>
<a class="jxr_linenumber" name="L4208" href="#L4208">4208</a> <em class="jxr_javadoccomment"> * Supported property names:&lt;ul&gt;</em>
<a class="jxr_linenumber" name="L4209" href="#L4209">4209</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@code picocli.color.commands}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L4210" href="#L4210">4210</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@code picocli.color.options}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L4211" href="#L4211">4211</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@code picocli.color.parameters}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L4212" href="#L4212">4212</a> <em class="jxr_javadoccomment"> * &lt;li&gt;{@code picocli.color.optionParams}&lt;/li&gt;</em>
<a class="jxr_linenumber" name="L4213" href="#L4213">4213</a> <em class="jxr_javadoccomment"> * &lt;/ul&gt;&lt;p&gt;Property values can be anything that {@link Help.Ansi.Style#parse(String)} can handle.&lt;/p&gt;</em>
<a class="jxr_linenumber" name="L4214" href="#L4214">4214</a> <em class="jxr_javadoccomment"> * @return this ColorScheme</em>
<a class="jxr_linenumber" name="L4215" href="#L4215">4215</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4216" href="#L4216">4216</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> applySystemProperties() {
<a class="jxr_linenumber" name="L4217" href="#L4217">4217</a> replace(commandStyles, System.getProperty(<span class="jxr_string">"picocli.color.commands"</span>));
<a class="jxr_linenumber" name="L4218" href="#L4218">4218</a> replace(optionStyles, System.getProperty(<span class="jxr_string">"picocli.color.options"</span>));
<a class="jxr_linenumber" name="L4219" href="#L4219">4219</a> replace(parameterStyles, System.getProperty(<span class="jxr_string">"picocli.color.parameters"</span>));
<a class="jxr_linenumber" name="L4220" href="#L4220">4220</a> replace(optionParamStyles, System.getProperty(<span class="jxr_string">"picocli.color.optionParams"</span>));
<a class="jxr_linenumber" name="L4221" href="#L4221">4221</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L4222" href="#L4222">4222</a> }
<a class="jxr_linenumber" name="L4223" href="#L4223">4223</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> replace(<strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; styles, <strong class="jxr_keyword">final</strong> String property) {
<a class="jxr_linenumber" name="L4224" href="#L4224">4224</a> <strong class="jxr_keyword">if</strong> (property != <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L4225" href="#L4225">4225</a> styles.clear();
<a class="jxr_linenumber" name="L4226" href="#L4226">4226</a> addAll(styles, Style.parse(property));
<a class="jxr_linenumber" name="L4227" href="#L4227">4227</a> }
<a class="jxr_linenumber" name="L4228" href="#L4228">4228</a> }
<a class="jxr_linenumber" name="L4229" href="#L4229">4229</a> <strong class="jxr_keyword">private</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> addAll(<strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; styles, <strong class="jxr_keyword">final</strong> IStyle... add) {
<a class="jxr_linenumber" name="L4230" href="#L4230">4230</a> styles.addAll(Arrays.asList(add));
<a class="jxr_linenumber" name="L4231" href="#L4231">4231</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>;
<a class="jxr_linenumber" name="L4232" href="#L4232">4232</a> }
<a class="jxr_linenumber" name="L4233" href="#L4233">4233</a>
<a class="jxr_linenumber" name="L4234" href="#L4234">4234</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi() {
<a class="jxr_linenumber" name="L4235" href="#L4235">4235</a> <strong class="jxr_keyword">return</strong> ansi;
<a class="jxr_linenumber" name="L4236" href="#L4236">4236</a> }
<a class="jxr_linenumber" name="L4237" href="#L4237">4237</a> }
<a class="jxr_linenumber" name="L4238" href="#L4238">4238</a>
<a class="jxr_linenumber" name="L4239" href="#L4239">4239</a> <em class="jxr_javadoccomment">/** Creates and returns a new {@link ColorScheme} initialized with picocli default values: commands are bold,</em>
<a class="jxr_linenumber" name="L4240" href="#L4240">4240</a> <em class="jxr_javadoccomment"> * options and parameters use a yellow foreground, and option parameters use italic.</em>
<a class="jxr_linenumber" name="L4241" href="#L4241">4241</a> <em class="jxr_javadoccomment"> * @param ansi whether the usage help message should contain ANSI escape codes or not</em>
<a class="jxr_linenumber" name="L4242" href="#L4242">4242</a> <em class="jxr_javadoccomment"> * @return a new default color scheme</em>
<a class="jxr_linenumber" name="L4243" href="#L4243">4243</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4244" href="#L4244">4244</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a> defaultColorScheme(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> ansi) {
<a class="jxr_linenumber" name="L4245" href="#L4245">4245</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ColorScheme</a>(ansi)
<a class="jxr_linenumber" name="L4246" href="#L4246">4246</a> .commands(Style.bold)
<a class="jxr_linenumber" name="L4247" href="#L4247">4247</a> .options(Style.fg_yellow)
<a class="jxr_linenumber" name="L4248" href="#L4248">4248</a> .parameters(Style.fg_yellow)
<a class="jxr_linenumber" name="L4249" href="#L4249">4249</a> .optionParams(Style.italic);
<a class="jxr_linenumber" name="L4250" href="#L4250">4250</a> }
<a class="jxr_linenumber" name="L4251" href="#L4251">4251</a>
<a class="jxr_linenumber" name="L4252" href="#L4252">4252</a> <em class="jxr_javadoccomment">/** Provides methods and inner classes to support using ANSI escape codes in usage help messages. */</em>
<a class="jxr_linenumber" name="L4253" href="#L4253">4253</a> <strong class="jxr_keyword">public</strong> enum <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Ansi</a> {
<a class="jxr_linenumber" name="L4254" href="#L4254">4254</a> <em class="jxr_javadoccomment">/** Only emit ANSI escape codes if the platform supports it and system property {@code "picocli.ansi"}</em>
<a class="jxr_linenumber" name="L4255" href="#L4255">4255</a> <em class="jxr_javadoccomment"> * is not set to any value other than {@code "true"} (case insensitive). */</em>
<a class="jxr_linenumber" name="L4256" href="#L4256">4256</a> AUTO,
<a class="jxr_linenumber" name="L4257" href="#L4257">4257</a> <em class="jxr_javadoccomment">/** Forced ON: always emit ANSI escape code regardless of the platform. */</em>
<a class="jxr_linenumber" name="L4258" href="#L4258">4258</a> ON,
<a class="jxr_linenumber" name="L4259" href="#L4259">4259</a> <em class="jxr_javadoccomment">/** Forced OFF: never emit ANSI escape code regardless of the platform. */</em>
<a class="jxr_linenumber" name="L4260" href="#L4260">4260</a> OFF;
<a class="jxr_linenumber" name="L4261" href="#L4261">4261</a> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> EMPTY_TEXT = OFF.<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(0);
<a class="jxr_linenumber" name="L4262" href="#L4262">4262</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> isWindows = System.getProperty(<span class="jxr_string">"os.name"</span>).startsWith(<span class="jxr_string">"Windows"</span>);
<a class="jxr_linenumber" name="L4263" href="#L4263">4263</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> isXterm = System.getenv(<span class="jxr_string">"TERM"</span>) != <strong class="jxr_keyword">null</strong> &amp;&amp; System.getenv(<span class="jxr_string">"TERM"</span>).startsWith(<span class="jxr_string">"xterm"</span>);
<a class="jxr_linenumber" name="L4264" href="#L4264">4264</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> ISATTY = calcTTY();
<a class="jxr_linenumber" name="L4265" href="#L4265">4265</a>
<a class="jxr_linenumber" name="L4266" href="#L4266">4266</a> <em class="jxr_comment">// http://stackoverflow.com/questions/1403772/how-can-i-check-if-a-java-programs-input-output-streams-are-connected-to-a-term</em>
<a class="jxr_linenumber" name="L4267" href="#L4267">4267</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> calcTTY() {
<a class="jxr_linenumber" name="L4268" href="#L4268">4268</a> <strong class="jxr_keyword">if</strong> (isWindows &amp;&amp; isXterm) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>; } <em class="jxr_comment">// Cygwin uses pseudo-tty and console is always null...</em>
<a class="jxr_linenumber" name="L4269" href="#L4269">4269</a> <strong class="jxr_keyword">try</strong> { <strong class="jxr_keyword">return</strong> System.<strong class="jxr_keyword">class</strong>.getDeclaredMethod(<span class="jxr_string">"console"</span>).invoke(<strong class="jxr_keyword">null</strong>) != <strong class="jxr_keyword">null</strong>; }
<a class="jxr_linenumber" name="L4270" href="#L4270">4270</a> <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Throwable reflectionFailed) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>; }
<a class="jxr_linenumber" name="L4271" href="#L4271">4271</a> }
<a class="jxr_linenumber" name="L4272" href="#L4272">4272</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> ansiPossible() { <strong class="jxr_keyword">return</strong> ISATTY &amp;&amp; (!isWindows || isXterm); }
<a class="jxr_linenumber" name="L4273" href="#L4273">4273</a>
<a class="jxr_linenumber" name="L4274" href="#L4274">4274</a> <em class="jxr_javadoccomment">/** Returns {@code true} if ANSI escape codes should be emitted, {@code false} otherwise.</em>
<a class="jxr_linenumber" name="L4275" href="#L4275">4275</a> <em class="jxr_javadoccomment"> * @return ON: {@code true}, OFF: {@code false}, AUTO: if system property {@code "picocli.ansi"} is</em>
<a class="jxr_linenumber" name="L4276" href="#L4276">4276</a> <em class="jxr_javadoccomment"> * defined then return its boolean value, otherwise return whether the platform supports ANSI escape codes */</em>
<a class="jxr_linenumber" name="L4277" href="#L4277">4277</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> enabled() {
<a class="jxr_linenumber" name="L4278" href="#L4278">4278</a> <strong class="jxr_keyword">if</strong> (<strong class="jxr_keyword">this</strong> == ON) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>; }
<a class="jxr_linenumber" name="L4279" href="#L4279">4279</a> <strong class="jxr_keyword">if</strong> (<strong class="jxr_keyword">this</strong> == OFF) { <strong class="jxr_keyword">return</strong> false; }
<a class="jxr_linenumber" name="L4280" href="#L4280">4280</a> <strong class="jxr_keyword">return</strong> (System.getProperty(<span class="jxr_string">"picocli.ansi"</span>) == <strong class="jxr_keyword">null</strong> ? ansiPossible() : Boolean.getBoolean(<span class="jxr_string">"picocli.ansi"</span>));
<a class="jxr_linenumber" name="L4281" href="#L4281">4281</a> }
<a class="jxr_linenumber" name="L4282" href="#L4282">4282</a>
<a class="jxr_linenumber" name="L4283" href="#L4283">4283</a> <em class="jxr_javadoccomment">/** Defines the interface for an ANSI escape sequence. */</em>
<a class="jxr_linenumber" name="L4284" href="#L4284">4284</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">interface</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a> {
<a class="jxr_linenumber" name="L4285" href="#L4285">4285</a>
<a class="jxr_linenumber" name="L4286" href="#L4286">4286</a> <em class="jxr_javadoccomment">/** The Control Sequence Introducer (CSI) escape sequence {@value}. */</em>
<a class="jxr_linenumber" name="L4287" href="#L4287">4287</a> String CSI = <span class="jxr_string">"\u001B["</span>;
<a class="jxr_linenumber" name="L4288" href="#L4288">4288</a>
<a class="jxr_linenumber" name="L4289" href="#L4289">4289</a> <em class="jxr_javadoccomment">/** Returns the ANSI escape code for turning this style on.</em>
<a class="jxr_linenumber" name="L4290" href="#L4290">4290</a> <em class="jxr_javadoccomment"> * @return the ANSI escape code for turning this style on */</em>
<a class="jxr_linenumber" name="L4291" href="#L4291">4291</a> String on();
<a class="jxr_linenumber" name="L4292" href="#L4292">4292</a>
<a class="jxr_linenumber" name="L4293" href="#L4293">4293</a> <em class="jxr_javadoccomment">/** Returns the ANSI escape code for turning this style off.</em>
<a class="jxr_linenumber" name="L4294" href="#L4294">4294</a> <em class="jxr_javadoccomment"> * @return the ANSI escape code for turning this style off */</em>
<a class="jxr_linenumber" name="L4295" href="#L4295">4295</a> String off();
<a class="jxr_linenumber" name="L4296" href="#L4296">4296</a> }
<a class="jxr_linenumber" name="L4297" href="#L4297">4297</a>
<a class="jxr_linenumber" name="L4298" href="#L4298">4298</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4299" href="#L4299">4299</a> <em class="jxr_javadoccomment"> * A set of pre-defined ANSI escape code styles and colors, and a set of convenience methods for parsing</em>
<a class="jxr_linenumber" name="L4300" href="#L4300">4300</a> <em class="jxr_javadoccomment"> * text with embedded markup style names, as well as convenience methods for converting</em>
<a class="jxr_linenumber" name="L4301" href="#L4301">4301</a> <em class="jxr_javadoccomment"> * styles to strings with embedded escape codes.</em>
<a class="jxr_linenumber" name="L4302" href="#L4302">4302</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4303" href="#L4303">4303</a> <strong class="jxr_keyword">public</strong> enum <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Style</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a> {
<a class="jxr_linenumber" name="L4304" href="#L4304">4304</a> reset(0, 0), bold(1, 21), faint(2, 22), italic(3, 23), underline(4, 24), blink(5, 25), reverse(7, 27),
<a class="jxr_linenumber" name="L4305" href="#L4305">4305</a> fg_black(30, 39), fg_red(31, 39), fg_green(32, 39), fg_yellow(33, 39), fg_blue(34, 39), fg_magenta(35, 39), fg_cyan(36, 39), fg_white(37, 39),
<a class="jxr_linenumber" name="L4306" href="#L4306">4306</a> bg_black(40, 49), bg_red(41, 49), bg_green(42, 49), bg_yellow(43, 49), bg_blue(44, 49), bg_magenta(45, 49), bg_cyan(46, 49), bg_white(47, 49),
<a class="jxr_linenumber" name="L4307" href="#L4307">4307</a> ;
<a class="jxr_linenumber" name="L4308" href="#L4308">4308</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> startCode;
<a class="jxr_linenumber" name="L4309" href="#L4309">4309</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> endCode;
<a class="jxr_linenumber" name="L4310" href="#L4310">4310</a>
<a class="jxr_linenumber" name="L4311" href="#L4311">4311</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Style</a>(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> startCode, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> endCode) {<strong class="jxr_keyword">this</strong>.startCode = startCode; <strong class="jxr_keyword">this</strong>.endCode = endCode; }
<a class="jxr_linenumber" name="L4312" href="#L4312">4312</a> @Override
<a class="jxr_linenumber" name="L4313" href="#L4313">4313</a> <strong class="jxr_keyword">public</strong> String on() { <strong class="jxr_keyword">return</strong> CSI + startCode + <span class="jxr_string">"m"</span>; }
<a class="jxr_linenumber" name="L4314" href="#L4314">4314</a> @Override
<a class="jxr_linenumber" name="L4315" href="#L4315">4315</a> <strong class="jxr_keyword">public</strong> String off() { <strong class="jxr_keyword">return</strong> CSI + endCode + <span class="jxr_string">"m"</span>; }
<a class="jxr_linenumber" name="L4316" href="#L4316">4316</a>
<a class="jxr_linenumber" name="L4317" href="#L4317">4317</a> <em class="jxr_javadoccomment">/** Returns the concatenated ANSI escape codes for turning all specified styles on.</em>
<a class="jxr_linenumber" name="L4318" href="#L4318">4318</a> <em class="jxr_javadoccomment"> * @param styles the styles to generate ANSI escape codes for</em>
<a class="jxr_linenumber" name="L4319" href="#L4319">4319</a> <em class="jxr_javadoccomment"> * @return the concatenated ANSI escape codes for turning all specified styles on */</em>
<a class="jxr_linenumber" name="L4320" href="#L4320">4320</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String on(<strong class="jxr_keyword">final</strong> IStyle... styles) {
<a class="jxr_linenumber" name="L4321" href="#L4321">4321</a> <strong class="jxr_keyword">final</strong> StringBuilder result = <strong class="jxr_keyword">new</strong> StringBuilder();
<a class="jxr_linenumber" name="L4322" href="#L4322">4322</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> IStyle style : styles) {
<a class="jxr_linenumber" name="L4323" href="#L4323">4323</a> result.append(style.on());
<a class="jxr_linenumber" name="L4324" href="#L4324">4324</a> }
<a class="jxr_linenumber" name="L4325" href="#L4325">4325</a> <strong class="jxr_keyword">return</strong> result.toString();
<a class="jxr_linenumber" name="L4326" href="#L4326">4326</a> }
<a class="jxr_linenumber" name="L4327" href="#L4327">4327</a> <em class="jxr_javadoccomment">/** Returns the concatenated ANSI escape codes for turning all specified styles off.</em>
<a class="jxr_linenumber" name="L4328" href="#L4328">4328</a> <em class="jxr_javadoccomment"> * @param styles the styles to generate ANSI escape codes for</em>
<a class="jxr_linenumber" name="L4329" href="#L4329">4329</a> <em class="jxr_javadoccomment"> * @return the concatenated ANSI escape codes for turning all specified styles off */</em>
<a class="jxr_linenumber" name="L4330" href="#L4330">4330</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String off(<strong class="jxr_keyword">final</strong> IStyle... styles) {
<a class="jxr_linenumber" name="L4331" href="#L4331">4331</a> <strong class="jxr_keyword">final</strong> StringBuilder result = <strong class="jxr_keyword">new</strong> StringBuilder();
<a class="jxr_linenumber" name="L4332" href="#L4332">4332</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> IStyle style : styles) {
<a class="jxr_linenumber" name="L4333" href="#L4333">4333</a> result.append(style.off());
<a class="jxr_linenumber" name="L4334" href="#L4334">4334</a> }
<a class="jxr_linenumber" name="L4335" href="#L4335">4335</a> <strong class="jxr_keyword">return</strong> result.toString();
<a class="jxr_linenumber" name="L4336" href="#L4336">4336</a> }
<a class="jxr_linenumber" name="L4337" href="#L4337">4337</a> <em class="jxr_javadoccomment">/** Parses the specified style markup and returns the associated style.</em>
<a class="jxr_linenumber" name="L4338" href="#L4338">4338</a> <em class="jxr_javadoccomment"> * The markup may be one of the Style enum value names, or it may be one of the Style enum value</em>
<a class="jxr_linenumber" name="L4339" href="#L4339">4339</a> <em class="jxr_javadoccomment"> * names when {@code "fg_"} is prepended, or it may be one of the indexed colors in the 256 color palette.</em>
<a class="jxr_linenumber" name="L4340" href="#L4340">4340</a> <em class="jxr_javadoccomment"> * @param str the case-insensitive style markup to convert, e.g. {@code "blue"} or {@code "fg_blue"},</em>
<a class="jxr_linenumber" name="L4341" href="#L4341">4341</a> <em class="jxr_javadoccomment"> * or {@code "46"} (indexed color) or {@code "0;5;0"} (RGB components of an indexed color)</em>
<a class="jxr_linenumber" name="L4342" href="#L4342">4342</a> <em class="jxr_javadoccomment"> * @return the IStyle for the specified converter</em>
<a class="jxr_linenumber" name="L4343" href="#L4343">4343</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4344" href="#L4344">4344</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a> fg(<strong class="jxr_keyword">final</strong> String str) {
<a class="jxr_linenumber" name="L4345" href="#L4345">4345</a> <strong class="jxr_keyword">try</strong> { <strong class="jxr_keyword">return</strong> Style.valueOf(str.toLowerCase(ENGLISH)); } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ignored) {}
<a class="jxr_linenumber" name="L4346" href="#L4346">4346</a> <strong class="jxr_keyword">try</strong> { <strong class="jxr_keyword">return</strong> Style.valueOf(<span class="jxr_string">"fg_"</span> + str.toLowerCase(ENGLISH)); } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ignored) {}
<a class="jxr_linenumber" name="L4347" href="#L4347">4347</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Palette256Color</a>(<strong class="jxr_keyword">true</strong>, str);
<a class="jxr_linenumber" name="L4348" href="#L4348">4348</a> }
<a class="jxr_linenumber" name="L4349" href="#L4349">4349</a> <em class="jxr_javadoccomment">/** Parses the specified style markup and returns the associated style.</em>
<a class="jxr_linenumber" name="L4350" href="#L4350">4350</a> <em class="jxr_javadoccomment"> * The markup may be one of the Style enum value names, or it may be one of the Style enum value</em>
<a class="jxr_linenumber" name="L4351" href="#L4351">4351</a> <em class="jxr_javadoccomment"> * names when {@code "bg_"} is prepended, or it may be one of the indexed colors in the 256 color palette.</em>
<a class="jxr_linenumber" name="L4352" href="#L4352">4352</a> <em class="jxr_javadoccomment"> * @param str the case-insensitive style markup to convert, e.g. {@code "blue"} or {@code "bg_blue"},</em>
<a class="jxr_linenumber" name="L4353" href="#L4353">4353</a> <em class="jxr_javadoccomment"> * or {@code "46"} (indexed color) or {@code "0;5;0"} (RGB components of an indexed color)</em>
<a class="jxr_linenumber" name="L4354" href="#L4354">4354</a> <em class="jxr_javadoccomment"> * @return the IStyle for the specified converter</em>
<a class="jxr_linenumber" name="L4355" href="#L4355">4355</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4356" href="#L4356">4356</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a> bg(<strong class="jxr_keyword">final</strong> String str) {
<a class="jxr_linenumber" name="L4357" href="#L4357">4357</a> <strong class="jxr_keyword">try</strong> { <strong class="jxr_keyword">return</strong> Style.valueOf(str.toLowerCase(ENGLISH)); } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ignored) {}
<a class="jxr_linenumber" name="L4358" href="#L4358">4358</a> <strong class="jxr_keyword">try</strong> { <strong class="jxr_keyword">return</strong> Style.valueOf(<span class="jxr_string">"bg_"</span> + str.toLowerCase(ENGLISH)); } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Exception ignored) {}
<a class="jxr_linenumber" name="L4359" href="#L4359">4359</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Palette256Color</a>(false, str);
<a class="jxr_linenumber" name="L4360" href="#L4360">4360</a> }
<a class="jxr_linenumber" name="L4361" href="#L4361">4361</a> <em class="jxr_javadoccomment">/** Parses the specified comma-separated sequence of style descriptors and returns the associated</em>
<a class="jxr_linenumber" name="L4362" href="#L4362">4362</a> <em class="jxr_javadoccomment"> * styles. For each markup, strings starting with {@code "bg("} are delegated to</em>
<a class="jxr_linenumber" name="L4363" href="#L4363">4363</a> <em class="jxr_javadoccomment"> * {@link #bg(String)}, others are delegated to {@link #bg(String)}.</em>
<a class="jxr_linenumber" name="L4364" href="#L4364">4364</a> <em class="jxr_javadoccomment"> * @param commaSeparatedCodes one or more descriptors, e.g. {@code "bg(blue),underline,red"}</em>
<a class="jxr_linenumber" name="L4365" href="#L4365">4365</a> <em class="jxr_javadoccomment"> * @return an array with all styles for the specified descriptors</em>
<a class="jxr_linenumber" name="L4366" href="#L4366">4366</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4367" href="#L4367">4367</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a>[] parse(<strong class="jxr_keyword">final</strong> String commaSeparatedCodes) {
<a class="jxr_linenumber" name="L4368" href="#L4368">4368</a> <strong class="jxr_keyword">final</strong> String[] codes = commaSeparatedCodes.split(<span class="jxr_string">","</span>);
<a class="jxr_linenumber" name="L4369" href="#L4369">4369</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a>[] styles = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a>[codes.length];
<a class="jxr_linenumber" name="L4370" href="#L4370">4370</a> <strong class="jxr_keyword">for</strong>(<strong class="jxr_keyword">int</strong> i = 0; i &lt; codes.length; ++i) {
<a class="jxr_linenumber" name="L4371" href="#L4371">4371</a> <strong class="jxr_keyword">if</strong> (codes[i].toLowerCase(ENGLISH).startsWith(<span class="jxr_string">"fg("</span>)) {
<a class="jxr_linenumber" name="L4372" href="#L4372">4372</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> end = codes[i].indexOf(')');
<a class="jxr_linenumber" name="L4373" href="#L4373">4373</a> styles[i] = Style.fg(codes[i].substring(3, end &lt; 0 ? codes[i].length() : end));
<a class="jxr_linenumber" name="L4374" href="#L4374">4374</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (codes[i].toLowerCase(ENGLISH).startsWith(<span class="jxr_string">"bg("</span>)) {
<a class="jxr_linenumber" name="L4375" href="#L4375">4375</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> end = codes[i].indexOf(')');
<a class="jxr_linenumber" name="L4376" href="#L4376">4376</a> styles[i] = Style.bg(codes[i].substring(3, end &lt; 0 ? codes[i].length() : end));
<a class="jxr_linenumber" name="L4377" href="#L4377">4377</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L4378" href="#L4378">4378</a> styles[i] = Style.fg(codes[i]);
<a class="jxr_linenumber" name="L4379" href="#L4379">4379</a> }
<a class="jxr_linenumber" name="L4380" href="#L4380">4380</a> }
<a class="jxr_linenumber" name="L4381" href="#L4381">4381</a> <strong class="jxr_keyword">return</strong> styles;
<a class="jxr_linenumber" name="L4382" href="#L4382">4382</a> }
<a class="jxr_linenumber" name="L4383" href="#L4383">4383</a> }
<a class="jxr_linenumber" name="L4384" href="#L4384">4384</a>
<a class="jxr_linenumber" name="L4385" href="#L4385">4385</a> <em class="jxr_javadoccomment">/** Defines a palette map of 216 colors: 6 * 6 * 6 cube (216 colors):</em>
<a class="jxr_linenumber" name="L4386" href="#L4386">4386</a> <em class="jxr_javadoccomment"> * 16 + 36 * r + 6 * g + b (0 &amp;lt;= r, g, b &amp;lt;= 5). */</em>
<a class="jxr_linenumber" name="L4387" href="#L4387">4387</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Palette256Color</a> <strong class="jxr_keyword">implements</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a> {
<a class="jxr_linenumber" name="L4388" href="#L4388">4388</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> fgbg;
<a class="jxr_linenumber" name="L4389" href="#L4389">4389</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> color;
<a class="jxr_linenumber" name="L4390" href="#L4390">4390</a>
<a class="jxr_linenumber" name="L4391" href="#L4391">4391</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Palette256Color</a>(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> foreground, <strong class="jxr_keyword">final</strong> String color) {
<a class="jxr_linenumber" name="L4392" href="#L4392">4392</a> <strong class="jxr_keyword">this</strong>.fgbg = foreground ? 38 : 48;
<a class="jxr_linenumber" name="L4393" href="#L4393">4393</a> <strong class="jxr_keyword">final</strong> String[] rgb = color.split(<span class="jxr_string">";"</span>);
<a class="jxr_linenumber" name="L4394" href="#L4394">4394</a> <strong class="jxr_keyword">if</strong> (rgb.length == 3) {
<a class="jxr_linenumber" name="L4395" href="#L4395">4395</a> <strong class="jxr_keyword">this</strong>.color = 16 + 36 * Integer.decode(rgb[0]) + 6 * Integer.decode(rgb[1]) + Integer.decode(rgb[2]);
<a class="jxr_linenumber" name="L4396" href="#L4396">4396</a> } <strong class="jxr_keyword">else</strong> {
<a class="jxr_linenumber" name="L4397" href="#L4397">4397</a> <strong class="jxr_keyword">this</strong>.color = Integer.decode(color);
<a class="jxr_linenumber" name="L4398" href="#L4398">4398</a> }
<a class="jxr_linenumber" name="L4399" href="#L4399">4399</a> }
<a class="jxr_linenumber" name="L4400" href="#L4400">4400</a> @Override
<a class="jxr_linenumber" name="L4401" href="#L4401">4401</a> <strong class="jxr_keyword">public</strong> String on() { <strong class="jxr_keyword">return</strong> String.format(CSI + <span class="jxr_string">"%d;5;%dm"</span>, fgbg, color); }
<a class="jxr_linenumber" name="L4402" href="#L4402">4402</a> @Override
<a class="jxr_linenumber" name="L4403" href="#L4403">4403</a> <strong class="jxr_keyword">public</strong> String off() { <strong class="jxr_keyword">return</strong> CSI + (fgbg + 1) + <span class="jxr_string">"m"</span>; }
<a class="jxr_linenumber" name="L4404" href="#L4404">4404</a> }
<a class="jxr_linenumber" name="L4405" href="#L4405">4405</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a> {
<a class="jxr_linenumber" name="L4406" href="#L4406">4406</a> <strong class="jxr_keyword">int</strong> startIndex, length;
<a class="jxr_linenumber" name="L4407" href="#L4407">4407</a> String startStyles, endStyles;
<a class="jxr_linenumber" name="L4408" href="#L4408">4408</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a>(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> start, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> len, <strong class="jxr_keyword">final</strong> String style1, <strong class="jxr_keyword">final</strong> String style2) {
<a class="jxr_linenumber" name="L4409" href="#L4409">4409</a> startIndex = start; length = len; startStyles = style1; endStyles = style2;
<a class="jxr_linenumber" name="L4410" href="#L4410">4410</a> }
<a class="jxr_linenumber" name="L4411" href="#L4411">4411</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a> withStartIndex(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> newStart) {
<a class="jxr_linenumber" name="L4412" href="#L4412">4412</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a>(newStart, length, startStyles, endStyles);
<a class="jxr_linenumber" name="L4413" href="#L4413">4413</a> }
<a class="jxr_linenumber" name="L4414" href="#L4414">4414</a> }
<a class="jxr_linenumber" name="L4415" href="#L4415">4415</a>
<a class="jxr_linenumber" name="L4416" href="#L4416">4416</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4417" href="#L4417">4417</a> <em class="jxr_javadoccomment"> * Returns a new Text object where all the specified styles are applied to the full length of the</em>
<a class="jxr_linenumber" name="L4418" href="#L4418">4418</a> <em class="jxr_javadoccomment"> * specified plain text.</em>
<a class="jxr_linenumber" name="L4419" href="#L4419">4419</a> <em class="jxr_javadoccomment"> * @param plainText the string to apply all styles to. Must not contain markup!</em>
<a class="jxr_linenumber" name="L4420" href="#L4420">4420</a> <em class="jxr_javadoccomment"> * @param styles the styles to apply to the full plain text</em>
<a class="jxr_linenumber" name="L4421" href="#L4421">4421</a> <em class="jxr_javadoccomment"> * @return a new Text object</em>
<a class="jxr_linenumber" name="L4422" href="#L4422">4422</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4423" href="#L4423">4423</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> apply(<strong class="jxr_keyword">final</strong> String plainText, <strong class="jxr_keyword">final</strong> List&lt;IStyle&gt; styles) {
<a class="jxr_linenumber" name="L4424" href="#L4424">4424</a> <strong class="jxr_keyword">if</strong> (plainText.length() == 0) { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> Text(0); }
<a class="jxr_linenumber" name="L4425" href="#L4425">4425</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> result = <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(plainText.length());
<a class="jxr_linenumber" name="L4426" href="#L4426">4426</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a>[] all = styles.toArray(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a>[styles.size()]);
<a class="jxr_linenumber" name="L4427" href="#L4427">4427</a> result.sections.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a>(
<a class="jxr_linenumber" name="L4428" href="#L4428">4428</a> 0, plainText.length(), Style.on(all), Style.off(reverse(all)) + Style.reset.off()));
<a class="jxr_linenumber" name="L4429" href="#L4429">4429</a> result.plain.append(plainText);
<a class="jxr_linenumber" name="L4430" href="#L4430">4430</a> result.length = result.plain.length();
<a class="jxr_linenumber" name="L4431" href="#L4431">4431</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L4432" href="#L4432">4432</a> }
<a class="jxr_linenumber" name="L4433" href="#L4433">4433</a>
<a class="jxr_linenumber" name="L4434" href="#L4434">4434</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> &lt;T&gt; T[] reverse(<strong class="jxr_keyword">final</strong> T[] all) {
<a class="jxr_linenumber" name="L4435" href="#L4435">4435</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; all.length / 2; i++) {
<a class="jxr_linenumber" name="L4436" href="#L4436">4436</a> <strong class="jxr_keyword">final</strong> T temp = all[i];
<a class="jxr_linenumber" name="L4437" href="#L4437">4437</a> all[i] = all[all.length - i - 1];
<a class="jxr_linenumber" name="L4438" href="#L4438">4438</a> all[all.length - i - 1] = temp;
<a class="jxr_linenumber" name="L4439" href="#L4439">4439</a> }
<a class="jxr_linenumber" name="L4440" href="#L4440">4440</a> <strong class="jxr_keyword">return</strong> all;
<a class="jxr_linenumber" name="L4441" href="#L4441">4441</a> }
<a class="jxr_linenumber" name="L4442" href="#L4442">4442</a> <em class="jxr_javadoccomment">/** Encapsulates rich text with styles and colors. Text objects may be constructed with Strings containing</em>
<a class="jxr_linenumber" name="L4443" href="#L4443">4443</a> <em class="jxr_javadoccomment"> * markup like {@code @|bg(red),white,underline some text|@}, and this class converts the markup to ANSI</em>
<a class="jxr_linenumber" name="L4444" href="#L4444">4444</a> <em class="jxr_javadoccomment"> * escape codes.</em>
<a class="jxr_linenumber" name="L4445" href="#L4445">4445</a> <em class="jxr_javadoccomment"> * &lt;p&gt;</em>
<a class="jxr_linenumber" name="L4446" href="#L4446">4446</a> <em class="jxr_javadoccomment"> * Internally keeps both an enriched and a plain text representation to allow layout components to calculate</em>
<a class="jxr_linenumber" name="L4447" href="#L4447">4447</a> <em class="jxr_javadoccomment"> * text width while remaining unaware of the embedded ANSI escape codes.&lt;/p&gt; */</em>
<a class="jxr_linenumber" name="L4448" href="#L4448">4448</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> <strong class="jxr_keyword">implements</strong> Cloneable {
<a class="jxr_linenumber" name="L4449" href="#L4449">4449</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> maxLength;
<a class="jxr_linenumber" name="L4450" href="#L4450">4450</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> from;
<a class="jxr_linenumber" name="L4451" href="#L4451">4451</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> length;
<a class="jxr_linenumber" name="L4452" href="#L4452">4452</a> <strong class="jxr_keyword">private</strong> StringBuilder plain = <strong class="jxr_keyword">new</strong> StringBuilder();
<a class="jxr_linenumber" name="L4453" href="#L4453">4453</a> <strong class="jxr_keyword">private</strong> List&lt;StyledSection&gt; sections = <strong class="jxr_keyword">new</strong> ArrayList&lt;StyledSection&gt;();
<a class="jxr_linenumber" name="L4454" href="#L4454">4454</a>
<a class="jxr_linenumber" name="L4455" href="#L4455">4455</a> <em class="jxr_javadoccomment">/** Constructs a Text with the specified max length (for use in a TextTable Column).</em>
<a class="jxr_linenumber" name="L4456" href="#L4456">4456</a> <em class="jxr_javadoccomment"> * @param maxLength max length of this text */</em>
<a class="jxr_linenumber" name="L4457" href="#L4457">4457</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> maxLength) { <strong class="jxr_keyword">this</strong>.maxLength = maxLength; }
<a class="jxr_linenumber" name="L4458" href="#L4458">4458</a>
<a class="jxr_linenumber" name="L4459" href="#L4459">4459</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4460" href="#L4460">4460</a> <em class="jxr_javadoccomment"> * Constructs a Text with the specified String, which may contain markup like</em>
<a class="jxr_linenumber" name="L4461" href="#L4461">4461</a> <em class="jxr_javadoccomment"> * {@code @|bg(red),white,underline some text|@}.</em>
<a class="jxr_linenumber" name="L4462" href="#L4462">4462</a> <em class="jxr_javadoccomment"> * @param input the string with markup to parse</em>
<a class="jxr_linenumber" name="L4463" href="#L4463">4463</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4464" href="#L4464">4464</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(<strong class="jxr_keyword">final</strong> String input) {
<a class="jxr_linenumber" name="L4465" href="#L4465">4465</a> maxLength = -1;
<a class="jxr_linenumber" name="L4466" href="#L4466">4466</a> plain.setLength(0);
<a class="jxr_linenumber" name="L4467" href="#L4467">4467</a> <strong class="jxr_keyword">int</strong> i = 0;
<a class="jxr_linenumber" name="L4468" href="#L4468">4468</a>
<a class="jxr_linenumber" name="L4469" href="#L4469">4469</a> <strong class="jxr_keyword">while</strong> (<strong class="jxr_keyword">true</strong>) {
<a class="jxr_linenumber" name="L4470" href="#L4470">4470</a> <strong class="jxr_keyword">int</strong> j = input.indexOf(<span class="jxr_string">"@|"</span>, i);
<a class="jxr_linenumber" name="L4471" href="#L4471">4471</a> <strong class="jxr_keyword">if</strong> (j == -1) {
<a class="jxr_linenumber" name="L4472" href="#L4472">4472</a> <strong class="jxr_keyword">if</strong> (i == 0) {
<a class="jxr_linenumber" name="L4473" href="#L4473">4473</a> plain.append(input);
<a class="jxr_linenumber" name="L4474" href="#L4474">4474</a> length = plain.length();
<a class="jxr_linenumber" name="L4475" href="#L4475">4475</a> <strong class="jxr_keyword">return</strong>;
<a class="jxr_linenumber" name="L4476" href="#L4476">4476</a> }
<a class="jxr_linenumber" name="L4477" href="#L4477">4477</a> plain.append(input.substring(i, input.length()));
<a class="jxr_linenumber" name="L4478" href="#L4478">4478</a> length = plain.length();
<a class="jxr_linenumber" name="L4479" href="#L4479">4479</a> <strong class="jxr_keyword">return</strong>;
<a class="jxr_linenumber" name="L4480" href="#L4480">4480</a> }
<a class="jxr_linenumber" name="L4481" href="#L4481">4481</a> plain.append(input.substring(i, j));
<a class="jxr_linenumber" name="L4482" href="#L4482">4482</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> k = input.indexOf(<span class="jxr_string">"|@"</span>, j);
<a class="jxr_linenumber" name="L4483" href="#L4483">4483</a> <strong class="jxr_keyword">if</strong> (k == -1) {
<a class="jxr_linenumber" name="L4484" href="#L4484">4484</a> plain.append(input);
<a class="jxr_linenumber" name="L4485" href="#L4485">4485</a> length = plain.length();
<a class="jxr_linenumber" name="L4486" href="#L4486">4486</a> <strong class="jxr_keyword">return</strong>;
<a class="jxr_linenumber" name="L4487" href="#L4487">4487</a> }
<a class="jxr_linenumber" name="L4488" href="#L4488">4488</a>
<a class="jxr_linenumber" name="L4489" href="#L4489">4489</a> j += 2;
<a class="jxr_linenumber" name="L4490" href="#L4490">4490</a> <strong class="jxr_keyword">final</strong> String spec = input.substring(j, k);
<a class="jxr_linenumber" name="L4491" href="#L4491">4491</a> <strong class="jxr_keyword">final</strong> String[] items = spec.split(<span class="jxr_string">" "</span>, 2);
<a class="jxr_linenumber" name="L4492" href="#L4492">4492</a> <strong class="jxr_keyword">if</strong> (items.length == 1) {
<a class="jxr_linenumber" name="L4493" href="#L4493">4493</a> plain.append(input);
<a class="jxr_linenumber" name="L4494" href="#L4494">4494</a> length = plain.length();
<a class="jxr_linenumber" name="L4495" href="#L4495">4495</a> <strong class="jxr_keyword">return</strong>;
<a class="jxr_linenumber" name="L4496" href="#L4496">4496</a> }
<a class="jxr_linenumber" name="L4497" href="#L4497">4497</a>
<a class="jxr_linenumber" name="L4498" href="#L4498">4498</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">IStyle</a>[] styles = Style.parse(items[0]);
<a class="jxr_linenumber" name="L4499" href="#L4499">4499</a> addStyledSection(plain.length(), items[1].length(),
<a class="jxr_linenumber" name="L4500" href="#L4500">4500</a> Style.on(styles), Style.off(reverse(styles)) + Style.reset.off());
<a class="jxr_linenumber" name="L4501" href="#L4501">4501</a> plain.append(items[1]);
<a class="jxr_linenumber" name="L4502" href="#L4502">4502</a> i = k + 2;
<a class="jxr_linenumber" name="L4503" href="#L4503">4503</a> }
<a class="jxr_linenumber" name="L4504" href="#L4504">4504</a> }
<a class="jxr_linenumber" name="L4505" href="#L4505">4505</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> addStyledSection(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> start, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length, <strong class="jxr_keyword">final</strong> String startStyle, <strong class="jxr_keyword">final</strong> String endStyle) {
<a class="jxr_linenumber" name="L4506" href="#L4506">4506</a> sections.add(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a>(start, length, startStyle, endStyle));
<a class="jxr_linenumber" name="L4507" href="#L4507">4507</a> }
<a class="jxr_linenumber" name="L4508" href="#L4508">4508</a> @Override
<a class="jxr_linenumber" name="L4509" href="#L4509">4509</a> <strong class="jxr_keyword">public</strong> Object clone() {
<a class="jxr_linenumber" name="L4510" href="#L4510">4510</a> <strong class="jxr_keyword">try</strong> { <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">super</strong>.clone(); } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> CloneNotSupportedException e) { <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException(e); }
<a class="jxr_linenumber" name="L4511" href="#L4511">4511</a> }
<a class="jxr_linenumber" name="L4512" href="#L4512">4512</a>
<a class="jxr_linenumber" name="L4513" href="#L4513">4513</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[] splitLines() {
<a class="jxr_linenumber" name="L4514" href="#L4514">4514</a> <strong class="jxr_keyword">final</strong> List&lt;Text&gt; result = <strong class="jxr_keyword">new</strong> ArrayList&lt;Text&gt;();
<a class="jxr_linenumber" name="L4515" href="#L4515">4515</a> <strong class="jxr_keyword">boolean</strong> trailingEmptyString = false;
<a class="jxr_linenumber" name="L4516" href="#L4516">4516</a> <strong class="jxr_keyword">int</strong> start = 0, end = 0;
<a class="jxr_linenumber" name="L4517" href="#L4517">4517</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; plain.length(); i++, end = i) {
<a class="jxr_linenumber" name="L4518" href="#L4518">4518</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">char</strong> c = plain.charAt(i);
<a class="jxr_linenumber" name="L4519" href="#L4519">4519</a> <strong class="jxr_keyword">boolean</strong> eol = c == '\n';
<a class="jxr_linenumber" name="L4520" href="#L4520">4520</a> eol |= (c == '\r' &amp;&amp; i + 1 &lt; plain.length() &amp;&amp; plain.charAt(i + 1) == '\n' &amp;&amp; ++i &gt; 0); <em class="jxr_comment">// \r\n</em>
<a class="jxr_linenumber" name="L4521" href="#L4521">4521</a> eol |= c == '\r';
<a class="jxr_linenumber" name="L4522" href="#L4522">4522</a> <strong class="jxr_keyword">if</strong> (eol) {
<a class="jxr_linenumber" name="L4523" href="#L4523">4523</a> result.add(<strong class="jxr_keyword">this</strong>.substring(start, end));
<a class="jxr_linenumber" name="L4524" href="#L4524">4524</a> trailingEmptyString = i == plain.length() - 1;
<a class="jxr_linenumber" name="L4525" href="#L4525">4525</a> start = i + 1;
<a class="jxr_linenumber" name="L4526" href="#L4526">4526</a> }
<a class="jxr_linenumber" name="L4527" href="#L4527">4527</a> }
<a class="jxr_linenumber" name="L4528" href="#L4528">4528</a> <strong class="jxr_keyword">if</strong> (start &lt; plain.length() || trailingEmptyString) {
<a class="jxr_linenumber" name="L4529" href="#L4529">4529</a> result.add(<strong class="jxr_keyword">this</strong>.substring(start, plain.length()));
<a class="jxr_linenumber" name="L4530" href="#L4530">4530</a> }
<a class="jxr_linenumber" name="L4531" href="#L4531">4531</a> <strong class="jxr_keyword">return</strong> result.toArray(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>[result.size()]);
<a class="jxr_linenumber" name="L4532" href="#L4532">4532</a> }
<a class="jxr_linenumber" name="L4533" href="#L4533">4533</a>
<a class="jxr_linenumber" name="L4534" href="#L4534">4534</a> <em class="jxr_javadoccomment">/** Returns a new {@code Text} instance that is a substring of this Text. Does not modify this instance!</em>
<a class="jxr_linenumber" name="L4535" href="#L4535">4535</a> <em class="jxr_javadoccomment"> * @param start index in the plain text where to start the substring</em>
<a class="jxr_linenumber" name="L4536" href="#L4536">4536</a> <em class="jxr_javadoccomment"> * @return a new Text instance that is a substring of this Text */</em>
<a class="jxr_linenumber" name="L4537" href="#L4537">4537</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> substring(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> start) {
<a class="jxr_linenumber" name="L4538" href="#L4538">4538</a> <strong class="jxr_keyword">return</strong> substring(start, length);
<a class="jxr_linenumber" name="L4539" href="#L4539">4539</a> }
<a class="jxr_linenumber" name="L4540" href="#L4540">4540</a>
<a class="jxr_linenumber" name="L4541" href="#L4541">4541</a> <em class="jxr_javadoccomment">/** Returns a new {@code Text} instance that is a substring of this Text. Does not modify this instance!</em>
<a class="jxr_linenumber" name="L4542" href="#L4542">4542</a> <em class="jxr_javadoccomment"> * @param start index in the plain text where to start the substring</em>
<a class="jxr_linenumber" name="L4543" href="#L4543">4543</a> <em class="jxr_javadoccomment"> * @param end index in the plain text where to end the substring</em>
<a class="jxr_linenumber" name="L4544" href="#L4544">4544</a> <em class="jxr_javadoccomment"> * @return a new Text instance that is a substring of this Text */</em>
<a class="jxr_linenumber" name="L4545" href="#L4545">4545</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> substring(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> start, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> end) {
<a class="jxr_linenumber" name="L4546" href="#L4546">4546</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> result = (Text) clone();
<a class="jxr_linenumber" name="L4547" href="#L4547">4547</a> result.from = from + start;
<a class="jxr_linenumber" name="L4548" href="#L4548">4548</a> result.length = end - start;
<a class="jxr_linenumber" name="L4549" href="#L4549">4549</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L4550" href="#L4550">4550</a> }
<a class="jxr_linenumber" name="L4551" href="#L4551">4551</a> <em class="jxr_javadoccomment">/** Returns a new {@code Text} instance with the specified text appended. Does not modify this instance!</em>
<a class="jxr_linenumber" name="L4552" href="#L4552">4552</a> <em class="jxr_javadoccomment"> * @param string the text to append</em>
<a class="jxr_linenumber" name="L4553" href="#L4553">4553</a> <em class="jxr_javadoccomment"> * @return a new Text instance */</em>
<a class="jxr_linenumber" name="L4554" href="#L4554">4554</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> append(<strong class="jxr_keyword">final</strong> String string) {
<a class="jxr_linenumber" name="L4555" href="#L4555">4555</a> <strong class="jxr_keyword">return</strong> append(<strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a>(string));
<a class="jxr_linenumber" name="L4556" href="#L4556">4556</a> }
<a class="jxr_linenumber" name="L4557" href="#L4557">4557</a>
<a class="jxr_linenumber" name="L4558" href="#L4558">4558</a> <em class="jxr_javadoccomment">/** Returns a new {@code Text} instance with the specified text appended. Does not modify this instance!</em>
<a class="jxr_linenumber" name="L4559" href="#L4559">4559</a> <em class="jxr_javadoccomment"> * @param other the text to append</em>
<a class="jxr_linenumber" name="L4560" href="#L4560">4560</a> <em class="jxr_javadoccomment"> * @return a new Text instance */</em>
<a class="jxr_linenumber" name="L4561" href="#L4561">4561</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> append(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> other) {
<a class="jxr_linenumber" name="L4562" href="#L4562">4562</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> result = (Text) clone();
<a class="jxr_linenumber" name="L4563" href="#L4563">4563</a> result.plain = <strong class="jxr_keyword">new</strong> StringBuilder(plain.toString().substring(from, from + length));
<a class="jxr_linenumber" name="L4564" href="#L4564">4564</a> result.from = 0;
<a class="jxr_linenumber" name="L4565" href="#L4565">4565</a> result.sections = <strong class="jxr_keyword">new</strong> ArrayList&lt;StyledSection&gt;();
<a class="jxr_linenumber" name="L4566" href="#L4566">4566</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> StyledSection section : sections) {
<a class="jxr_linenumber" name="L4567" href="#L4567">4567</a> result.sections.add(section.withStartIndex(section.startIndex - from));
<a class="jxr_linenumber" name="L4568" href="#L4568">4568</a> }
<a class="jxr_linenumber" name="L4569" href="#L4569">4569</a> result.plain.append(other.plain.toString().substring(other.from, other.from + other.length));
<a class="jxr_linenumber" name="L4570" href="#L4570">4570</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> StyledSection section : other.sections) {
<a class="jxr_linenumber" name="L4571" href="#L4571">4571</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> index = result.length + section.startIndex - other.from;
<a class="jxr_linenumber" name="L4572" href="#L4572">4572</a> result.sections.add(section.withStartIndex(index));
<a class="jxr_linenumber" name="L4573" href="#L4573">4573</a> }
<a class="jxr_linenumber" name="L4574" href="#L4574">4574</a> result.length = result.plain.length();
<a class="jxr_linenumber" name="L4575" href="#L4575">4575</a> <strong class="jxr_keyword">return</strong> result;
<a class="jxr_linenumber" name="L4576" href="#L4576">4576</a> }
<a class="jxr_linenumber" name="L4577" href="#L4577">4577</a>
<a class="jxr_linenumber" name="L4578" href="#L4578">4578</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4579" href="#L4579">4579</a> <em class="jxr_javadoccomment"> * Copies the specified substring of this Text into the specified destination, preserving the markup.</em>
<a class="jxr_linenumber" name="L4580" href="#L4580">4580</a> <em class="jxr_javadoccomment"> * @param from start of the substring</em>
<a class="jxr_linenumber" name="L4581" href="#L4581">4581</a> <em class="jxr_javadoccomment"> * @param length length of the substring</em>
<a class="jxr_linenumber" name="L4582" href="#L4582">4582</a> <em class="jxr_javadoccomment"> * @param destination destination Text to modify</em>
<a class="jxr_linenumber" name="L4583" href="#L4583">4583</a> <em class="jxr_javadoccomment"> * @param offset indentation (padding)</em>
<a class="jxr_linenumber" name="L4584" href="#L4584">4584</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4585" href="#L4585">4585</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> getStyledChars(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> from, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> length, <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Text</a> destination, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> offset) {
<a class="jxr_linenumber" name="L4586" href="#L4586">4586</a> <strong class="jxr_keyword">if</strong> (destination.length &lt; offset) {
<a class="jxr_linenumber" name="L4587" href="#L4587">4587</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = destination.length; i &lt; offset; i++) {
<a class="jxr_linenumber" name="L4588" href="#L4588">4588</a> destination.plain.append(' ');
<a class="jxr_linenumber" name="L4589" href="#L4589">4589</a> }
<a class="jxr_linenumber" name="L4590" href="#L4590">4590</a> destination.length = offset;
<a class="jxr_linenumber" name="L4591" href="#L4591">4591</a> }
<a class="jxr_linenumber" name="L4592" href="#L4592">4592</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> StyledSection section : sections) {
<a class="jxr_linenumber" name="L4593" href="#L4593">4593</a> destination.sections.add(section.withStartIndex(section.startIndex - from + destination.length));
<a class="jxr_linenumber" name="L4594" href="#L4594">4594</a> }
<a class="jxr_linenumber" name="L4595" href="#L4595">4595</a> destination.plain.append(plain.toString().substring(from, from + length));
<a class="jxr_linenumber" name="L4596" href="#L4596">4596</a> destination.length = destination.plain.length();
<a class="jxr_linenumber" name="L4597" href="#L4597">4597</a> }
<a class="jxr_linenumber" name="L4598" href="#L4598">4598</a> <em class="jxr_javadoccomment">/** Returns the plain text without any formatting.</em>
<a class="jxr_linenumber" name="L4599" href="#L4599">4599</a> <em class="jxr_javadoccomment"> * @return the plain text without any formatting */</em>
<a class="jxr_linenumber" name="L4600" href="#L4600">4600</a> <strong class="jxr_keyword">public</strong> String plainString() { <strong class="jxr_keyword">return</strong> plain.toString().substring(from, from + length); }
<a class="jxr_linenumber" name="L4601" href="#L4601">4601</a>
<a class="jxr_linenumber" name="L4602" href="#L4602">4602</a> @Override
<a class="jxr_linenumber" name="L4603" href="#L4603">4603</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> equals(<strong class="jxr_keyword">final</strong> Object obj) { <strong class="jxr_keyword">return</strong> toString().equals(String.valueOf(obj)); }
<a class="jxr_linenumber" name="L4604" href="#L4604">4604</a> @Override
<a class="jxr_linenumber" name="L4605" href="#L4605">4605</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> hashCode() { <strong class="jxr_keyword">return</strong> toString().hashCode(); }
<a class="jxr_linenumber" name="L4606" href="#L4606">4606</a>
<a class="jxr_linenumber" name="L4607" href="#L4607">4607</a> <em class="jxr_javadoccomment">/** Returns a String representation of the text with ANSI escape codes embedded, unless ANSI is</em>
<a class="jxr_linenumber" name="L4608" href="#L4608">4608</a> <em class="jxr_javadoccomment"> * {@linkplain Ansi#enabled()} not enabled}, in which case the plain text is returned.</em>
<a class="jxr_linenumber" name="L4609" href="#L4609">4609</a> <em class="jxr_javadoccomment"> * @return a String representation of the text with ANSI escape codes embedded (if enabled) */</em>
<a class="jxr_linenumber" name="L4610" href="#L4610">4610</a> @Override
<a class="jxr_linenumber" name="L4611" href="#L4611">4611</a> <strong class="jxr_keyword">public</strong> String toString() {
<a class="jxr_linenumber" name="L4612" href="#L4612">4612</a> <strong class="jxr_keyword">if</strong> (!Ansi.<strong class="jxr_keyword">this</strong>.enabled()) {
<a class="jxr_linenumber" name="L4613" href="#L4613">4613</a> <strong class="jxr_keyword">return</strong> plain.toString().substring(from, from + length);
<a class="jxr_linenumber" name="L4614" href="#L4614">4614</a> }
<a class="jxr_linenumber" name="L4615" href="#L4615">4615</a> <strong class="jxr_keyword">if</strong> (length == 0) { <strong class="jxr_keyword">return</strong> <span class="jxr_string">""</span>; }
<a class="jxr_linenumber" name="L4616" href="#L4616">4616</a> <strong class="jxr_keyword">final</strong> StringBuilder sb = <strong class="jxr_keyword">new</strong> StringBuilder(plain.length() + 20 * sections.size());
<a class="jxr_linenumber" name="L4617" href="#L4617">4617</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a> current = <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L4618" href="#L4618">4618</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> end = Math.min(from + length, plain.length());
<a class="jxr_linenumber" name="L4619" href="#L4619">4619</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = from; i &lt; end; i++) {
<a class="jxr_linenumber" name="L4620" href="#L4620">4620</a> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a> section = findSectionContaining(i);
<a class="jxr_linenumber" name="L4621" href="#L4621">4621</a> <strong class="jxr_keyword">if</strong> (section != current) {
<a class="jxr_linenumber" name="L4622" href="#L4622">4622</a> <strong class="jxr_keyword">if</strong> (current != <strong class="jxr_keyword">null</strong>) { sb.append(current.endStyles); }
<a class="jxr_linenumber" name="L4623" href="#L4623">4623</a> <strong class="jxr_keyword">if</strong> (section != <strong class="jxr_keyword">null</strong>) { sb.append(section.startStyles); }
<a class="jxr_linenumber" name="L4624" href="#L4624">4624</a> current = section;
<a class="jxr_linenumber" name="L4625" href="#L4625">4625</a> }
<a class="jxr_linenumber" name="L4626" href="#L4626">4626</a> sb.append(plain.charAt(i));
<a class="jxr_linenumber" name="L4627" href="#L4627">4627</a> }
<a class="jxr_linenumber" name="L4628" href="#L4628">4628</a> <strong class="jxr_keyword">if</strong> (current != <strong class="jxr_keyword">null</strong>) { sb.append(current.endStyles); }
<a class="jxr_linenumber" name="L4629" href="#L4629">4629</a> <strong class="jxr_keyword">return</strong> sb.toString();
<a class="jxr_linenumber" name="L4630" href="#L4630">4630</a> }
<a class="jxr_linenumber" name="L4631" href="#L4631">4631</a>
<a class="jxr_linenumber" name="L4632" href="#L4632">4632</a> <strong class="jxr_keyword">private</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">StyledSection</a> findSectionContaining(<strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> index) {
<a class="jxr_linenumber" name="L4633" href="#L4633">4633</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> StyledSection section : sections) {
<a class="jxr_linenumber" name="L4634" href="#L4634">4634</a> <strong class="jxr_keyword">if</strong> (index &gt;= section.startIndex &amp;&amp; index &lt; section.startIndex + section.length) {
<a class="jxr_linenumber" name="L4635" href="#L4635">4635</a> <strong class="jxr_keyword">return</strong> section;
<a class="jxr_linenumber" name="L4636" href="#L4636">4636</a> }
<a class="jxr_linenumber" name="L4637" href="#L4637">4637</a> }
<a class="jxr_linenumber" name="L4638" href="#L4638">4638</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
<a class="jxr_linenumber" name="L4639" href="#L4639">4639</a> }
<a class="jxr_linenumber" name="L4640" href="#L4640">4640</a> }
<a class="jxr_linenumber" name="L4641" href="#L4641">4641</a> }
<a class="jxr_linenumber" name="L4642" href="#L4642">4642</a> }
<a class="jxr_linenumber" name="L4643" href="#L4643">4643</a>
<a class="jxr_linenumber" name="L4644" href="#L4644">4644</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4645" href="#L4645">4645</a> <em class="jxr_javadoccomment"> * Utility class providing some defensive coding convenience methods.</em>
<a class="jxr_linenumber" name="L4646" href="#L4646">4646</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4647" href="#L4647">4647</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Assert</a> {
<a class="jxr_linenumber" name="L4648" href="#L4648">4648</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4649" href="#L4649">4649</a> <em class="jxr_javadoccomment"> * Throws a NullPointerException if the specified object is null.</em>
<a class="jxr_linenumber" name="L4650" href="#L4650">4650</a> <em class="jxr_javadoccomment"> * @param object the object to verify</em>
<a class="jxr_linenumber" name="L4651" href="#L4651">4651</a> <em class="jxr_javadoccomment"> * @param description error message</em>
<a class="jxr_linenumber" name="L4652" href="#L4652">4652</a> <em class="jxr_javadoccomment"> * @param &lt;T&gt; type of the object to check</em>
<a class="jxr_linenumber" name="L4653" href="#L4653">4653</a> <em class="jxr_javadoccomment"> * @return the verified object</em>
<a class="jxr_linenumber" name="L4654" href="#L4654">4654</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4655" href="#L4655">4655</a> <strong class="jxr_keyword">static</strong> &lt;T&gt; T notNull(<strong class="jxr_keyword">final</strong> T object, <strong class="jxr_keyword">final</strong> String description) {
<a class="jxr_linenumber" name="L4656" href="#L4656">4656</a> <strong class="jxr_keyword">if</strong> (object == <strong class="jxr_keyword">null</strong>) {
<a class="jxr_linenumber" name="L4657" href="#L4657">4657</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> NullPointerException(description);
<a class="jxr_linenumber" name="L4658" href="#L4658">4658</a> }
<a class="jxr_linenumber" name="L4659" href="#L4659">4659</a> <strong class="jxr_keyword">return</strong> object;
<a class="jxr_linenumber" name="L4660" href="#L4660">4660</a> }
<a class="jxr_linenumber" name="L4661" href="#L4661">4661</a> <strong class="jxr_keyword">private</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Assert</a>() {} <em class="jxr_comment">// private constructor: never instantiate</em>
<a class="jxr_linenumber" name="L4662" href="#L4662">4662</a> }
<a class="jxr_linenumber" name="L4663" href="#L4663">4663</a> <strong class="jxr_keyword">private</strong> enum <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TraceLevel</a> { OFF, WARN, INFO, DEBUG;
<a class="jxr_linenumber" name="L4664" href="#L4664">4664</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> isEnabled(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TraceLevel</a> other) { <strong class="jxr_keyword">return</strong> ordinal() &gt;= other.ordinal(); }
<a class="jxr_linenumber" name="L4665" href="#L4665">4665</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> print(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Tracer</a> tracer, <strong class="jxr_keyword">final</strong> String msg, <strong class="jxr_keyword">final</strong> Object... params) {
<a class="jxr_linenumber" name="L4666" href="#L4666">4666</a> <strong class="jxr_keyword">if</strong> (tracer.level.isEnabled(<strong class="jxr_keyword">this</strong>)) { tracer.stream.printf(prefix(msg), params); }
<a class="jxr_linenumber" name="L4667" href="#L4667">4667</a> }
<a class="jxr_linenumber" name="L4668" href="#L4668">4668</a> <strong class="jxr_keyword">private</strong> String prefix(<strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">return</strong> <span class="jxr_string">"[picocli "</span> + <strong class="jxr_keyword">this</strong> + <span class="jxr_string">"] "</span> + msg; }
<a class="jxr_linenumber" name="L4669" href="#L4669">4669</a> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TraceLevel</a> lookup(<strong class="jxr_keyword">final</strong> String key) { <strong class="jxr_keyword">return</strong> key == <strong class="jxr_keyword">null</strong> ? WARN : empty(key) || <span class="jxr_string">"true"</span>.equalsIgnoreCase(key) ? INFO : valueOf(key); }
<a class="jxr_linenumber" name="L4670" href="#L4670">4670</a> }
<a class="jxr_linenumber" name="L4671" href="#L4671">4671</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">Tracer</a> {
<a class="jxr_linenumber" name="L4672" href="#L4672">4672</a> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TraceLevel</a> level = TraceLevel.lookup(System.getProperty(<span class="jxr_string">"picocli.trace"</span>));
<a class="jxr_linenumber" name="L4673" href="#L4673">4673</a> PrintStream stream = System.err;
<a class="jxr_linenumber" name="L4674" href="#L4674">4674</a> <strong class="jxr_keyword">void</strong> warn (<strong class="jxr_keyword">final</strong> String msg, <strong class="jxr_keyword">final</strong> Object... params) { TraceLevel.WARN.print(<strong class="jxr_keyword">this</strong>, msg, params); }
<a class="jxr_linenumber" name="L4675" href="#L4675">4675</a> <strong class="jxr_keyword">void</strong> info (<strong class="jxr_keyword">final</strong> String msg, <strong class="jxr_keyword">final</strong> Object... params) { TraceLevel.INFO.print(<strong class="jxr_keyword">this</strong>, msg, params); }
<a class="jxr_linenumber" name="L4676" href="#L4676">4676</a> <strong class="jxr_keyword">void</strong> debug(<strong class="jxr_keyword">final</strong> String msg, <strong class="jxr_keyword">final</strong> Object... params) { TraceLevel.DEBUG.print(<strong class="jxr_keyword">this</strong>, msg, params); }
<a class="jxr_linenumber" name="L4677" href="#L4677">4677</a> <strong class="jxr_keyword">boolean</strong> isWarn() { <strong class="jxr_keyword">return</strong> level.isEnabled(TraceLevel.WARN); }
<a class="jxr_linenumber" name="L4678" href="#L4678">4678</a> <strong class="jxr_keyword">boolean</strong> isInfo() { <strong class="jxr_keyword">return</strong> level.isEnabled(TraceLevel.INFO); }
<a class="jxr_linenumber" name="L4679" href="#L4679">4679</a> <strong class="jxr_keyword">boolean</strong> isDebug() { <strong class="jxr_keyword">return</strong> level.isEnabled(TraceLevel.DEBUG); }
<a class="jxr_linenumber" name="L4680" href="#L4680">4680</a> }
<a class="jxr_linenumber" name="L4681" href="#L4681">4681</a> <em class="jxr_javadoccomment">/** Base class of all exceptions thrown by {@code picocli.CommandLine}.</em>
<a class="jxr_linenumber" name="L4682" href="#L4682">4682</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L4683" href="#L4683">4683</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PicocliException</a> <strong class="jxr_keyword">extends</strong> RuntimeException {
<a class="jxr_linenumber" name="L4684" href="#L4684">4684</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = -2574128880125050818L;
<a class="jxr_linenumber" name="L4685" href="#L4685">4685</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PicocliException</a>(<strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(msg); }
<a class="jxr_linenumber" name="L4686" href="#L4686">4686</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PicocliException</a>(<strong class="jxr_keyword">final</strong> String msg, <strong class="jxr_keyword">final</strong> Exception ex) { <strong class="jxr_keyword">super</strong>(msg, ex); }
<a class="jxr_linenumber" name="L4687" href="#L4687">4687</a> }
<a class="jxr_linenumber" name="L4688" href="#L4688">4688</a> <em class="jxr_javadoccomment">/** Exception indicating a problem during {@code CommandLine} initialization.</em>
<a class="jxr_linenumber" name="L4689" href="#L4689">4689</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L4690" href="#L4690">4690</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InitializationException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PicocliException</a> {
<a class="jxr_linenumber" name="L4691" href="#L4691">4691</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = 8423014001666638895L;
<a class="jxr_linenumber" name="L4692" href="#L4692">4692</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InitializationException</a>(<strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(msg); }
<a class="jxr_linenumber" name="L4693" href="#L4693">4693</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InitializationException</a>(<strong class="jxr_keyword">final</strong> String msg, <strong class="jxr_keyword">final</strong> Exception ex) { <strong class="jxr_keyword">super</strong>(msg, ex); }
<a class="jxr_linenumber" name="L4694" href="#L4694">4694</a> }
<a class="jxr_linenumber" name="L4695" href="#L4695">4695</a> <em class="jxr_javadoccomment">/** Exception indicating a problem while invoking a command or subcommand.</em>
<a class="jxr_linenumber" name="L4696" href="#L4696">4696</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L4697" href="#L4697">4697</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ExecutionException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PicocliException</a> {
<a class="jxr_linenumber" name="L4698" href="#L4698">4698</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = 7764539594267007998L;
<a class="jxr_linenumber" name="L4699" href="#L4699">4699</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine;
<a class="jxr_linenumber" name="L4700" href="#L4700">4700</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ExecutionException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg) {
<a class="jxr_linenumber" name="L4701" href="#L4701">4701</a> <strong class="jxr_keyword">super</strong>(msg);
<a class="jxr_linenumber" name="L4702" href="#L4702">4702</a> <strong class="jxr_keyword">this</strong>.commandLine = Assert.notNull(commandLine, <span class="jxr_string">"commandLine"</span>);
<a class="jxr_linenumber" name="L4703" href="#L4703">4703</a> }
<a class="jxr_linenumber" name="L4704" href="#L4704">4704</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ExecutionException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg, <strong class="jxr_keyword">final</strong> Exception ex) {
<a class="jxr_linenumber" name="L4705" href="#L4705">4705</a> <strong class="jxr_keyword">super</strong>(msg, ex);
<a class="jxr_linenumber" name="L4706" href="#L4706">4706</a> <strong class="jxr_keyword">this</strong>.commandLine = Assert.notNull(commandLine, <span class="jxr_string">"commandLine"</span>);
<a class="jxr_linenumber" name="L4707" href="#L4707">4707</a> }
<a class="jxr_linenumber" name="L4708" href="#L4708">4708</a> <em class="jxr_javadoccomment">/** Returns the {@code CommandLine} object for the (sub)command that could not be invoked.</em>
<a class="jxr_linenumber" name="L4709" href="#L4709">4709</a> <em class="jxr_javadoccomment"> * @return the {@code CommandLine} object for the (sub)command where invocation failed.</em>
<a class="jxr_linenumber" name="L4710" href="#L4710">4710</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4711" href="#L4711">4711</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> getCommandLine() { <strong class="jxr_keyword">return</strong> commandLine; }
<a class="jxr_linenumber" name="L4712" href="#L4712">4712</a> }
<a class="jxr_linenumber" name="L4713" href="#L4713">4713</a>
<a class="jxr_linenumber" name="L4714" href="#L4714">4714</a> <em class="jxr_javadoccomment">/** Exception thrown by {@link ITypeConverter} implementations to indicate a String could not be converted. */</em>
<a class="jxr_linenumber" name="L4715" href="#L4715">4715</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TypeConversionException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PicocliException</a> {
<a class="jxr_linenumber" name="L4716" href="#L4716">4716</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = 4251973913816346114L;
<a class="jxr_linenumber" name="L4717" href="#L4717">4717</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">TypeConversionException</a>(<strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(msg); }
<a class="jxr_linenumber" name="L4718" href="#L4718">4718</a> }
<a class="jxr_linenumber" name="L4719" href="#L4719">4719</a> <em class="jxr_javadoccomment">/** Exception indicating something went wrong while parsing command line options. */</em>
<a class="jxr_linenumber" name="L4720" href="#L4720">4720</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">PicocliException</a> {
<a class="jxr_linenumber" name="L4721" href="#L4721">4721</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = 1477112829129763139L;
<a class="jxr_linenumber" name="L4722" href="#L4722">4722</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine;
<a class="jxr_linenumber" name="L4723" href="#L4723">4723</a>
<a class="jxr_linenumber" name="L4724" href="#L4724">4724</a> <em class="jxr_javadoccomment">/** Constructs a new ParameterException with the specified CommandLine and error message.</em>
<a class="jxr_linenumber" name="L4725" href="#L4725">4725</a> <em class="jxr_javadoccomment"> * @param commandLine the command or subcommand whose input was invalid</em>
<a class="jxr_linenumber" name="L4726" href="#L4726">4726</a> <em class="jxr_javadoccomment"> * @param msg describes the problem</em>
<a class="jxr_linenumber" name="L4727" href="#L4727">4727</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L4728" href="#L4728">4728</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg) {
<a class="jxr_linenumber" name="L4729" href="#L4729">4729</a> <strong class="jxr_keyword">super</strong>(msg);
<a class="jxr_linenumber" name="L4730" href="#L4730">4730</a> <strong class="jxr_keyword">this</strong>.commandLine = Assert.notNull(commandLine, <span class="jxr_string">"commandLine"</span>);
<a class="jxr_linenumber" name="L4731" href="#L4731">4731</a> }
<a class="jxr_linenumber" name="L4732" href="#L4732">4732</a> <em class="jxr_javadoccomment">/** Constructs a new ParameterException with the specified CommandLine and error message.</em>
<a class="jxr_linenumber" name="L4733" href="#L4733">4733</a> <em class="jxr_javadoccomment"> * @param commandLine the command or subcommand whose input was invalid</em>
<a class="jxr_linenumber" name="L4734" href="#L4734">4734</a> <em class="jxr_javadoccomment"> * @param msg describes the problem</em>
<a class="jxr_linenumber" name="L4735" href="#L4735">4735</a> <em class="jxr_javadoccomment"> * @param ex the exception that caused this ParameterException</em>
<a class="jxr_linenumber" name="L4736" href="#L4736">4736</a> <em class="jxr_javadoccomment"> * @since 2.0 */</em>
<a class="jxr_linenumber" name="L4737" href="#L4737">4737</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg, <strong class="jxr_keyword">final</strong> Exception ex) {
<a class="jxr_linenumber" name="L4738" href="#L4738">4738</a> <strong class="jxr_keyword">super</strong>(msg, ex);
<a class="jxr_linenumber" name="L4739" href="#L4739">4739</a> <strong class="jxr_keyword">this</strong>.commandLine = Assert.notNull(commandLine, <span class="jxr_string">"commandLine"</span>);
<a class="jxr_linenumber" name="L4740" href="#L4740">4740</a> }
<a class="jxr_linenumber" name="L4741" href="#L4741">4741</a>
<a class="jxr_linenumber" name="L4742" href="#L4742">4742</a> <em class="jxr_javadoccomment">/** Returns the {@code CommandLine} object for the (sub)command whose input could not be parsed.</em>
<a class="jxr_linenumber" name="L4743" href="#L4743">4743</a> <em class="jxr_javadoccomment"> * @return the {@code CommandLine} object for the (sub)command where parsing failed.</em>
<a class="jxr_linenumber" name="L4744" href="#L4744">4744</a> <em class="jxr_javadoccomment"> * @since 2.0</em>
<a class="jxr_linenumber" name="L4745" href="#L4745">4745</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4746" href="#L4746">4746</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> getCommandLine() { <strong class="jxr_keyword">return</strong> commandLine; }
<a class="jxr_linenumber" name="L4747" href="#L4747">4747</a>
<a class="jxr_linenumber" name="L4748" href="#L4748">4748</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> create(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> cmd, <strong class="jxr_keyword">final</strong> Exception ex, <strong class="jxr_keyword">final</strong> String arg, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> i, <strong class="jxr_keyword">final</strong> String[] args) {
<a class="jxr_linenumber" name="L4749" href="#L4749">4749</a> <strong class="jxr_keyword">final</strong> String msg = ex.getClass().getSimpleName() + <span class="jxr_string">": "</span> + ex.getLocalizedMessage()
<a class="jxr_linenumber" name="L4750" href="#L4750">4750</a> + <span class="jxr_string">" while processing argument at or before arg["</span> + i + <span class="jxr_string">"] '"</span> + arg + <span class="jxr_string">"' in "</span> + Arrays.toString(args) + <span class="jxr_string">": "</span> + ex.toString();
<a class="jxr_linenumber" name="L4751" href="#L4751">4751</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a>(cmd, msg, ex);
<a class="jxr_linenumber" name="L4752" href="#L4752">4752</a> }
<a class="jxr_linenumber" name="L4753" href="#L4753">4753</a> }
<a class="jxr_linenumber" name="L4754" href="#L4754">4754</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4755" href="#L4755">4755</a> <em class="jxr_javadoccomment"> * Exception indicating that a required parameter was not specified.</em>
<a class="jxr_linenumber" name="L4756" href="#L4756">4756</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4757" href="#L4757">4757</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> {
<a class="jxr_linenumber" name="L4758" href="#L4758">4758</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = 5075678535706338753L;
<a class="jxr_linenumber" name="L4759" href="#L4759">4759</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg) {
<a class="jxr_linenumber" name="L4760" href="#L4760">4760</a> <strong class="jxr_keyword">super</strong>(commandLine, msg);
<a class="jxr_linenumber" name="L4761" href="#L4761">4761</a> }
<a class="jxr_linenumber" name="L4762" href="#L4762">4762</a>
<a class="jxr_linenumber" name="L4763" href="#L4763">4763</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a> create(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> cmd, <strong class="jxr_keyword">final</strong> Collection&lt;Field&gt; missing, <strong class="jxr_keyword">final</strong> String separator) {
<a class="jxr_linenumber" name="L4764" href="#L4764">4764</a> <strong class="jxr_keyword">if</strong> (missing.size() == 1) {
<a class="jxr_linenumber" name="L4765" href="#L4765">4765</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a>(cmd, <span class="jxr_string">"Missing required option '"</span>
<a class="jxr_linenumber" name="L4766" href="#L4766">4766</a> + describe(missing.iterator().next(), separator) + <span class="jxr_string">"'"</span>);
<a class="jxr_linenumber" name="L4767" href="#L4767">4767</a> }
<a class="jxr_linenumber" name="L4768" href="#L4768">4768</a> <strong class="jxr_keyword">final</strong> List&lt;String&gt; names = <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;(missing.size());
<a class="jxr_linenumber" name="L4769" href="#L4769">4769</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Field field : missing) {
<a class="jxr_linenumber" name="L4770" href="#L4770">4770</a> names.add(describe(field, separator));
<a class="jxr_linenumber" name="L4771" href="#L4771">4771</a> }
<a class="jxr_linenumber" name="L4772" href="#L4772">4772</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingParameterException</a>(cmd, <span class="jxr_string">"Missing required options "</span> + names.toString());
<a class="jxr_linenumber" name="L4773" href="#L4773">4773</a> }
<a class="jxr_linenumber" name="L4774" href="#L4774">4774</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String describe(<strong class="jxr_keyword">final</strong> Field field, <strong class="jxr_keyword">final</strong> String separator) {
<a class="jxr_linenumber" name="L4775" href="#L4775">4775</a> <strong class="jxr_keyword">final</strong> String prefix = (field.isAnnotationPresent(Option.<strong class="jxr_keyword">class</strong>))
<a class="jxr_linenumber" name="L4776" href="#L4776">4776</a> ? field.getAnnotation(Option.<strong class="jxr_keyword">class</strong>).names()[0] + separator
<a class="jxr_linenumber" name="L4777" href="#L4777">4777</a> : <span class="jxr_string">"params["</span> + field.getAnnotation(Parameters.<strong class="jxr_keyword">class</strong>).index() + <span class="jxr_string">"]"</span> + separator;
<a class="jxr_linenumber" name="L4778" href="#L4778">4778</a> <strong class="jxr_keyword">return</strong> prefix + Help.DefaultParamLabelRenderer.renderParameterName(field);
<a class="jxr_linenumber" name="L4779" href="#L4779">4779</a> }
<a class="jxr_linenumber" name="L4780" href="#L4780">4780</a> }
<a class="jxr_linenumber" name="L4781" href="#L4781">4781</a>
<a class="jxr_linenumber" name="L4782" href="#L4782">4782</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4783" href="#L4783">4783</a> <em class="jxr_javadoccomment"> * Exception indicating that multiple fields have been annotated with the same Option name.</em>
<a class="jxr_linenumber" name="L4784" href="#L4784">4784</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4785" href="#L4785">4785</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DuplicateOptionAnnotationsException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InitializationException</a> {
<a class="jxr_linenumber" name="L4786" href="#L4786">4786</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = -3355128012575075641L;
<a class="jxr_linenumber" name="L4787" href="#L4787">4787</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DuplicateOptionAnnotationsException</a>(<strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(msg); }
<a class="jxr_linenumber" name="L4788" href="#L4788">4788</a>
<a class="jxr_linenumber" name="L4789" href="#L4789">4789</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DuplicateOptionAnnotationsException</a> create(<strong class="jxr_keyword">final</strong> String name, <strong class="jxr_keyword">final</strong> Field field1, <strong class="jxr_keyword">final</strong> Field field2) {
<a class="jxr_linenumber" name="L4790" href="#L4790">4790</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">DuplicateOptionAnnotationsException</a>(<span class="jxr_string">"Option name '"</span> + name + <span class="jxr_string">"' is used by both "</span> +
<a class="jxr_linenumber" name="L4791" href="#L4791">4791</a> field1.getDeclaringClass().getName() + <span class="jxr_string">"."</span> + field1.getName() + <span class="jxr_string">" and "</span> +
<a class="jxr_linenumber" name="L4792" href="#L4792">4792</a> field2.getDeclaringClass().getName() + <span class="jxr_string">"."</span> + field2.getName());
<a class="jxr_linenumber" name="L4793" href="#L4793">4793</a> }
<a class="jxr_linenumber" name="L4794" href="#L4794">4794</a> }
<a class="jxr_linenumber" name="L4795" href="#L4795">4795</a> <em class="jxr_javadoccomment">/** Exception indicating that there was a gap in the indices of the fields annotated with {@link Parameters}. */</em>
<a class="jxr_linenumber" name="L4796" href="#L4796">4796</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterIndexGapException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">InitializationException</a> {
<a class="jxr_linenumber" name="L4797" href="#L4797">4797</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = -1520981133257618319L;
<a class="jxr_linenumber" name="L4798" href="#L4798">4798</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterIndexGapException</a>(<strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(msg); }
<a class="jxr_linenumber" name="L4799" href="#L4799">4799</a> }
<a class="jxr_linenumber" name="L4800" href="#L4800">4800</a> <em class="jxr_javadoccomment">/** Exception indicating that a command line argument could not be mapped to any of the fields annotated with</em>
<a class="jxr_linenumber" name="L4801" href="#L4801">4801</a> <em class="jxr_javadoccomment"> * {@link Option} or {@link Parameters}. */</em>
<a class="jxr_linenumber" name="L4802" href="#L4802">4802</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">UnmatchedArgumentException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> {
<a class="jxr_linenumber" name="L4803" href="#L4803">4803</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = -8700426380701452440L;
<a class="jxr_linenumber" name="L4804" href="#L4804">4804</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">UnmatchedArgumentException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(commandLine, msg); }
<a class="jxr_linenumber" name="L4805" href="#L4805">4805</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">UnmatchedArgumentException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> Stack&lt;String&gt; args) { <strong class="jxr_keyword">this</strong>(commandLine, <strong class="jxr_keyword">new</strong> ArrayList&lt;String&gt;(reverse(args))); }
<a class="jxr_linenumber" name="L4806" href="#L4806">4806</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">UnmatchedArgumentException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> List&lt;String&gt; args) { <strong class="jxr_keyword">this</strong>(commandLine, <span class="jxr_string">"Unmatched argument"</span> + (args.size() == 1 ? <span class="jxr_string">" "</span> : <span class="jxr_string">"s "</span>) + args); }
<a class="jxr_linenumber" name="L4807" href="#L4807">4807</a> }
<a class="jxr_linenumber" name="L4808" href="#L4808">4808</a> <em class="jxr_javadoccomment">/** Exception indicating that more values were specified for an option or parameter than its {@link Option#arity() arity} allows. */</em>
<a class="jxr_linenumber" name="L4809" href="#L4809">4809</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MaxValuesforFieldExceededException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> {
<a class="jxr_linenumber" name="L4810" href="#L4810">4810</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = 6536145439570100641L;
<a class="jxr_linenumber" name="L4811" href="#L4811">4811</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MaxValuesforFieldExceededException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(commandLine, msg); }
<a class="jxr_linenumber" name="L4812" href="#L4812">4812</a> }
<a class="jxr_linenumber" name="L4813" href="#L4813">4813</a> <em class="jxr_javadoccomment">/** Exception indicating that an option for a single-value option field has been specified multiple times on the command line. */</em>
<a class="jxr_linenumber" name="L4814" href="#L4814">4814</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">OverwrittenOptionException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> {
<a class="jxr_linenumber" name="L4815" href="#L4815">4815</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = 1338029208271055776L;
<a class="jxr_linenumber" name="L4816" href="#L4816">4816</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">OverwrittenOptionException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(commandLine, msg); }
<a class="jxr_linenumber" name="L4817" href="#L4817">4817</a> }
<a class="jxr_linenumber" name="L4818" href="#L4818">4818</a> <em class="jxr_javadoccomment">/**</em>
<a class="jxr_linenumber" name="L4819" href="#L4819">4819</a> <em class="jxr_javadoccomment"> * Exception indicating that an annotated field had a type for which no {@link ITypeConverter} was</em>
<a class="jxr_linenumber" name="L4820" href="#L4820">4820</a> <em class="jxr_javadoccomment"> * {@linkplain #registerConverter(Class, ITypeConverter) registered}.</em>
<a class="jxr_linenumber" name="L4821" href="#L4821">4821</a> <em class="jxr_javadoccomment"> */</em>
<a class="jxr_linenumber" name="L4822" href="#L4822">4822</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingTypeConverterException</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">ParameterException</a> {
<a class="jxr_linenumber" name="L4823" href="#L4823">4823</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">long</strong> serialVersionUID = -6050931703233083760L;
<a class="jxr_linenumber" name="L4824" href="#L4824">4824</a> <strong class="jxr_keyword">public</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">MissingTypeConverterException</a>(<strong class="jxr_keyword">final</strong> <a href="../../../../../../../org/apache/logging/log4j/core/tools/picocli/CommandLine.html">CommandLine</a> commandLine, <strong class="jxr_keyword">final</strong> String msg) { <strong class="jxr_keyword">super</strong>(commandLine, msg); }
<a class="jxr_linenumber" name="L4825" href="#L4825">4825</a> }
<a class="jxr_linenumber" name="L4826" href="#L4826">4826</a> }
</pre>
<hr/>
<div id="footer">Copyright &#169; 1999&#x2013;2019 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</div>
</body>
</html>