Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D44B6E4A9 for ; Tue, 5 Feb 2013 09:17:45 +0000 (UTC) Received: (qmail 55818 invoked by uid 500); 5 Feb 2013 09:17:44 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 55560 invoked by uid 500); 5 Feb 2013 09:17:43 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 55528 invoked by uid 99); 5 Feb 2013 09:17:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Feb 2013 09:17:42 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of thomas.neidhart@gmail.com designates 209.85.128.51 as permitted sender) Received: from [209.85.128.51] (HELO mail-qe0-f51.google.com) (209.85.128.51) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Feb 2013 09:17:36 +0000 Received: by mail-qe0-f51.google.com with SMTP id 6so3245436qea.24 for ; Tue, 05 Feb 2013 01:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=Lkz+rb9WbLOXXn5iNy3qAyfKdOUNMHmxq4/b/1t3Rk0=; b=htD8J8C2v7zIC9dTPzxjueH/Pvb0nk+NOwubGBGlMPA5d0feaNKw+he3/1T1FmewZl 7hHYyxTp1ifGhgI9NMuD88lkvqY3GcgSC3E6+l26IIi25FoLRRO6kIhOoNAwBvd8UIRd F/lAf40Xgea7oIqCD4UrtcIhd29T2NdZgAt0eVcC1Zdq1zEZqr+vASCn+n8c/MfhkIgK QPk0YyCXLUjKFiqtGiXm16DTCfDPcquF+eCsfosBaZWg5iSIZXh03k8yDrLLRvB7EYVS 8aspUfQmiIKeEzaCVmvqzAHUVKTHyaGcsK3K7HM1+tcqv0eAsm59AokOZLG26CXGzino FxQw== MIME-Version: 1.0 X-Received: by 10.49.133.68 with SMTP id pa4mr22929549qeb.50.1360055835623; Tue, 05 Feb 2013 01:17:15 -0800 (PST) Received: by 10.49.84.5 with HTTP; Tue, 5 Feb 2013 01:17:15 -0800 (PST) In-Reply-To: <510ECEF0.7000308@gmail.com> References: <510ECEF0.7000308@gmail.com> Date: Tue, 5 Feb 2013 10:17:15 +0100 Message-ID: Subject: Re: [CLI] - withValueSeparator() usage From: Thomas Neidhart To: Commons Users List Content-Type: multipart/alternative; boundary=047d7bd6b99cf5019304d4f6ac12 X-Virus-Checked: Checked by ClamAV on apache.org --047d7bd6b99cf5019304d4f6ac12 Content-Type: text/plain; charset=ISO-8859-1 On Sun, Feb 3, 2013 at 9:56 PM, Thomas Neidhart wrote: > On 02/03/2013 06:29 PM, Greg Thomas wrote: > > I've had a look; I the only place that could do with clarification is > > the javadoc for getOptionValues @ > > > http://commons.apache.org/cli/api-release/org/apache/commons/cli/CommandLine.html#getOptionValues(java.lang.String) > > / > http://commons.apache.org/cli/api-release/org/apache/commons/cli/CommandLine.html#getOptionValues(char) > > > > Currently, both say: > > > > "Retrieves the array of values, if any, of an option." > > > > I'd suggest something like; > > > > Where a valueSeparator is used to separate two argument values, these > > will return both values in an array of length 2. > > @see OptionBuilder#withValueSeparator() > > I think the examples provided in OptionBuilder#withValueSeparator() and > OptionBulder#withValueSeparator(char) should be improved to clearly > indicate that this separator is only used to distinguish between key and > value, and not to split values itself. > I did look further into this issue, and The value separator is only used in the Option#processValue method and is indeed used to split the argument into multiple values. Now, the splitting is only performed if in the OptionBuilder, the hasArgs() is specified with the number of expected argument values. With the default setting of hasArg(), like in the example above, no splitting will be performed. The example above also worked, because the option and arguments are separated by whitespace and thus provided as separate tokens to the parser. In this case, the argument is always the next token, regardless of the separator. If you would specify hasArgs(3), you would indeed get the values split into an array of 3 strings. Thomas --047d7bd6b99cf5019304d4f6ac12--