Coverage Report - com.lexicalscope.jewel.cli.HelpMessageBuilderImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpMessageBuilderImpl
83%
26/31
N/A
1
 
 1  
 package com.lexicalscope.jewel.cli;
 2  
 
 3  
 /*
 4  
  * Copyright 2011 Tim Wood
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License. 
 17  
  */
 18  
 
 19  26
 class HelpMessageBuilderImpl implements HelpMessage {
 20  26
     private final StringBuilder message = new StringBuilder();
 21  
 
 22  
     @Override public void noUsageInformation() {
 23  22
         message.append("The options available are:");
 24  22
     }
 25  
 
 26  
     @Override public void hasUsageInformation(final String applicationName) {
 27  4
         hasUsageInformation();
 28  4
         message.append(String.format("%s ", applicationName));
 29  4
     }
 30  
 
 31  
     @Override public void hasUsageInformation() {
 32  4
         message.append("Usage: ");
 33  4
     }
 34  
 
 35  
     @Override public void hasOnlyOptionalOptions() {
 36  4
         message.append("[");
 37  4
         message.append("options");
 38  4
         message.append("]");
 39  4
     }
 40  
 
 41  
     @Override public void hasSomeMandatoryOptions() {
 42  0
         message.append("options");
 43  0
     }
 44  
 
 45  
     @Override public void hasUnparsedMultiValuedOption(final String valueName) {
 46  4
         message.append(" ");
 47  4
         message.append(valueName);
 48  4
         message.append("...");
 49  4
     }
 50  
 
 51  
     @Override public void hasUnparsedOption(final String valueName) {
 52  0
         message.append(" ");
 53  0
         message.append(valueName);
 54  0
     }
 55  
 
 56  26
     private final String lineSeparator = System.getProperty("line.separator");
 57  26
     private String separator = "";
 58  
 
 59  
     @Override public void startOfOptions() {
 60  26
         message.append(lineSeparator);
 61  26
     }
 62  
 
 63  
     @Override public OptionHelpMessage option() {
 64  90
         message.append(separator).append("\t");
 65  90
         separator = lineSeparator;
 66  90
         return new HelpMessageOptionSummaryBuilderImpl(message);
 67  
     }
 68  
 
 69  
     @Override public void endOfOptions() {
 70  
         // OK
 71  26
     }
 72  
 
 73  
     @Override public String toString() {
 74  26
         return message.toString();
 75  
     }
 76  
 }