Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 41899 invoked from network); 5 Nov 2007 16:31:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Nov 2007 16:31:12 -0000 Received: (qmail 62852 invoked by uid 500); 5 Nov 2007 16:30:59 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 62798 invoked by uid 500); 5 Nov 2007 16:30:59 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 62789 invoked by uid 99); 5 Nov 2007 16:30:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 08:30:59 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 16:31:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B3B601A9832; Mon, 5 Nov 2007 08:30:47 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r592068 - in /incubator/cxf/branches/2.0.x-fixes: ./ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/ tools/common/src/test/java/org/apache/cxf/tools/common/tool... Date: Mon, 05 Nov 2007 16:30:47 -0000 To: cxf-commits@incubator.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071105163047.B3B601A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Mon Nov 5 08:30:46 2007 New Revision: 592068 URL: http://svn.apache.org/viewvc?rev=592068&view=rev Log: Merged revisions 591788 via svnmerge from https://svn.apache.org/repos/asf/incubator/cxf/trunk ........ r591788 | ema | 2007-11-04 10:12:10 -0500 (Sun, 04 Nov 2007) | 1 line CXF-1170: Improve the format of tooling help detailed usage, use the unix man style to print help message ........ Modified: incubator/cxf/branches/2.0.x-fixes/ (props changed) incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/detailedUsage.xsl incubator/cxf/branches/2.0.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java Propchange: incubator/cxf/branches/2.0.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java?rev=592068&r1=592067&r2=592068&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java (original) +++ incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/AbstractCXFToolContainer.java Mon Nov 5 08:30:46 2007 @@ -88,12 +88,10 @@ System.out.println(); System.out.println("Options: "); System.out.println(); - System.out.println(parser.getDetailedUsage()); + System.out.println(parser.getFromatedDetailedUsage()); String toolUsage = parser.getToolUsage(); - if (toolUsage != null) { System.out.println(toolUsage); - System.out.println(); } } catch (Exception ex) { System.err.println("Error : Could not output detailed usage"); Modified: incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java?rev=592068&r1=592067&r2=592068&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java (original) +++ incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java Mon Nov 5 08:30:46 2007 @@ -189,9 +189,91 @@ // REVISIT: style usage document into a form more readily output as a // usage message ByteArrayOutputStream baos = new ByteArrayOutputStream(); - toolspec.transform(getClass().getResourceAsStream("detailedUsage.xsl"), baos); return baos.toString(); + } + + public String getFromatedDetailedUsage() throws TransformerException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + toolspec.transform(getClass().getResourceAsStream("detailedUsage.xsl"), baos); + String usage = baos.toString(); + // we use the following pattern to format usage + // |-------|-options|------|description-----------------| + // before option white space size is 7 + int beforeOptSpan = 3; + // option lenght is 8 + int optSize = 12; + // after option white space size is 6 + int afterOptLen = 6; + int totalLen = 80; + int optSpan = optSize + afterOptLen - 1; + int beforeDesSpan = beforeOptSpan + optSpan + 1; + String lineSeparator = System.getProperty("line.separator"); + StringTokenizer st1 = new StringTokenizer(usage, lineSeparator); + int i = 0; + int length = st1.countTokens(); + String[] orginalStrs = new String[length]; + while (st1.hasMoreTokens()) { + String str = st1.nextToken(); + orginalStrs[i] = str; + i++; + } + StringBuffer strbuffer = new StringBuffer(); + for (int j = 0; j < length - 1; j = j + 2) { + int optionLen = orginalStrs[j].length(); + addWhiteNamespace(strbuffer, beforeOptSpan); + if (optionLen <= optSpan) { + // && beforeOptSpan + optionLen + optSpan + desLen <= totalLen - + // 1) { + + strbuffer.append(orginalStrs[j]); + addWhiteNamespace(strbuffer, optSpan - orginalStrs[j].length()); + strbuffer.append(" "); + if (orginalStrs[j + 1].length() > totalLen - beforeDesSpan) { + String tmp = orginalStrs[j + 1].substring(0, totalLen - beforeDesSpan); + strbuffer.append(tmp); + orginalStrs[j + 1] = orginalStrs[j + 1].substring(totalLen - beforeDesSpan, + orginalStrs[j + 1].length()); + strbuffer.append(lineSeparator); + } else { + strbuffer.append(orginalStrs[j + 1]); + strbuffer.append(lineSeparator); + orginalStrs[j + 1] = ""; + } + + // strbuffer.append(orginalStrs[j + 1]); + // strbuffer.append(lineSeparator); + // strbuffer.append(lineSeparator); + } else { + // addWhiteNamespace(strbuffer, beforeOptSpan); + strbuffer.append(orginalStrs[j]); + strbuffer.append(lineSeparator); + } + String tmpStr = orginalStrs[j + 1]; + + for (i = 0; i < tmpStr.length(); i = i + (totalLen - beforeDesSpan)) { + if (i + totalLen - beforeDesSpan < tmpStr.length()) { + addWhiteNamespace(strbuffer, beforeDesSpan); + strbuffer.append(tmpStr.substring(i, i + totalLen - beforeDesSpan)); + strbuffer.append(lineSeparator); + } else { + addWhiteNamespace(strbuffer, beforeDesSpan); + strbuffer.append(tmpStr.substring(i)); + strbuffer.append(lineSeparator); + } + } + strbuffer.append(lineSeparator); + + } + + return strbuffer.toString(); + } + + private void addWhiteNamespace(StringBuffer strbuffer, int count) { + + for (int i = 0; i < count; i++) { + strbuffer.append(" "); + } } public String getDetailedUsage(String id) { Modified: incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/detailedUsage.xsl URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/detailedUsage.xsl?rev=592068&r1=592067&r2=592068&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/detailedUsage.xsl (original) +++ incubator/cxf/branches/2.0.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/detailedUsage.xsl Mon Nov 5 08:30:46 2007 @@ -1,25 +1,27 @@ - - - + + + + @@ -81,8 +80,9 @@ - - + + + @@ -106,12 +106,13 @@ - - + + + - - - + + + Modified: incubator/cxf/branches/2.0.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java?rev=592068&r1=592067&r2=592068&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java (original) +++ incubator/cxf/branches/2.0.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParserTest.java Mon Nov 5 08:30:46 2007 @@ -303,5 +303,14 @@ public void testGetDetailedUsage() { assertTrue("Namespace".equals(parser.getDetailedUsage("namespace"))); } + + + @Test + public void testFormatedDetailedUsage() throws Exception { + String usage = parser.getFromatedDetailedUsage(); + assertNotNull(usage); + StringTokenizer st1 = new StringTokenizer(usage, System.getProperty("line.separator")); + assertEquals(13, st1.countTokens()); + } }