Class BashCompletionGenerator<T>
- java.lang.Object
-
- com.github.rvesse.airline.help.common.AbstractUsageGenerator
-
- com.github.rvesse.airline.help.common.AbstractGlobalUsageGenerator<T>
-
- com.github.rvesse.airline.help.cli.bash.BashCompletionGenerator<T>
-
- All Implemented Interfaces:
GlobalUsageGenerator<T>
public class BashCompletionGenerator<T> extends AbstractGlobalUsageGenerator<T>
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DOUBLE_NEWLINE
private static char
NEWLINE
private boolean
withDebugging
-
Fields inherited from class com.github.rvesse.airline.help.common.AbstractUsageGenerator
DEFAULT_COLUMNS
-
-
Constructor Summary
Constructors Constructor Description BashCompletionGenerator()
BashCompletionGenerator(boolean includeHidden, boolean enableDebugging)
Creates a new completion generator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
bashize(java.lang.String value)
private void
generateCommandCompletionFunction(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, CommandMetadata command)
private void
generateCommandFunctions(GlobalMetadata<T> global, java.io.Writer writer)
private void
generateGroupCompletionFunction(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group)
private void
generateGroupFunctions(GlobalMetadata<T> global, java.io.Writer writer)
protected BashCompletion
getCompletionData(ArgumentsMetadata arguments)
Gets the completion info for argumentsprotected BashCompletion
getCompletionData(OptionMetadata option)
Gets the completion info for an optionprotected BashCompletion
getCompletionData(java.util.Collection<Accessor> accessors)
private void
indent(java.io.Writer writer, int indent)
private void
repeat(java.io.Writer writer, int count, char c)
void
usage(GlobalMetadata<T> global, java.io.OutputStream output)
Generate the help and output it to the streamprivate void
writeCommandCase(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, CommandMetadata command, int indent, boolean isNestedFunction)
private void
writeCommandFunctionCall(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, CommandMetadata command, int indent)
private void
writeCommandFunctionName(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, CommandMetadata command, boolean declare)
private void
writeCompletionGeneration(java.io.Writer writer, int indent, boolean isNestedFunction, BashCompletion completion, java.lang.String... varNames)
private void
writeFunctionName(java.io.Writer writer, GlobalMetadata<T> global, boolean declare)
private void
writeGroupCase(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, int indent)
private void
writeGroupFunctionCall(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, int indent)
private void
writeGroupFunctionName(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, boolean declare)
private void
writeHeader(java.io.Writer writer)
private void
writeHelperFunctions(java.io.Writer writer)
private void
writeWordListVariable(java.io.Writer writer, int indent, java.lang.String varName, java.util.Iterator<java.lang.String> words)
-
Methods inherited from class com.github.rvesse.airline.help.common.AbstractGlobalUsageGenerator
findHelpSections, sortCommandGroups, usage
-
Methods inherited from class com.github.rvesse.airline.help.common.AbstractUsageGenerator
getCommandComparator, getOptionComparator, htmlize, includeHidden, sortArgumentsRestrictions, sortCommands, sortOptionRestrictions, sortOptions, toDefaultCommand, toDescription, toDescription, toSynopsisUsage, toUsage, toUsage
-
-
-
-
Field Detail
-
NEWLINE
private static final char NEWLINE
- See Also:
- Constant Field Values
-
DOUBLE_NEWLINE
private static final java.lang.String DOUBLE_NEWLINE
- See Also:
- Constant Field Values
-
withDebugging
private final boolean withDebugging
-
-
Constructor Detail
-
BashCompletionGenerator
public BashCompletionGenerator()
-
BashCompletionGenerator
public BashCompletionGenerator(boolean includeHidden, boolean enableDebugging)
Creates a new completion generator- Parameters:
enableDebugging
- Whether to enable debugging, when true the generated script will doset -o xtrace
in its functions andset +o xtrace
at the end of its functions
-
-
Method Detail
-
usage
public void usage(GlobalMetadata<T> global, java.io.OutputStream output) throws java.io.IOException
Description copied from interface:GlobalUsageGenerator
Generate the help and output it to the stream- Parameters:
global
- Global metadataoutput
- Stream to output to- Throws:
java.io.IOException
- Thrown if there is a problem generating usage output
-
generateCommandFunctions
private void generateCommandFunctions(GlobalMetadata<T> global, java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
generateGroupFunctions
private void generateGroupFunctions(GlobalMetadata<T> global, java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
writeHeader
private void writeHeader(java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
writeHelperFunctions
private void writeHelperFunctions(java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCommandCase
private void writeCommandCase(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, CommandMetadata command, int indent, boolean isNestedFunction) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCommandFunctionCall
private void writeCommandFunctionCall(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, CommandMetadata command, int indent) throws java.io.IOException
- Throws:
java.io.IOException
-
writeGroupCase
private void writeGroupCase(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, int indent) throws java.io.IOException
- Throws:
java.io.IOException
-
writeGroupFunctionCall
private void writeGroupFunctionCall(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, int indent) throws java.io.IOException
- Throws:
java.io.IOException
-
generateGroupCompletionFunction
private void generateGroupCompletionFunction(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group) throws java.io.IOException
- Throws:
java.io.IOException
-
generateCommandCompletionFunction
private void generateCommandCompletionFunction(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, CommandMetadata command) throws java.io.IOException
- Throws:
java.io.IOException
-
indent
private void indent(java.io.Writer writer, int indent) throws java.io.IOException
- Throws:
java.io.IOException
-
repeat
private void repeat(java.io.Writer writer, int count, char c) throws java.io.IOException
- Throws:
java.io.IOException
-
writeWordListVariable
private void writeWordListVariable(java.io.Writer writer, int indent, java.lang.String varName, java.util.Iterator<java.lang.String> words) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFunctionName
private void writeFunctionName(java.io.Writer writer, GlobalMetadata<T> global, boolean declare) throws java.io.IOException
- Throws:
java.io.IOException
-
writeGroupFunctionName
private void writeGroupFunctionName(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, boolean declare) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCommandFunctionName
private void writeCommandFunctionName(java.io.Writer writer, GlobalMetadata<T> global, CommandGroupMetadata group, CommandMetadata command, boolean declare) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCompletionGeneration
private void writeCompletionGeneration(java.io.Writer writer, int indent, boolean isNestedFunction, BashCompletion completion, java.lang.String... varNames) throws java.io.IOException
- Throws:
java.io.IOException
-
bashize
private java.lang.String bashize(java.lang.String value)
-
getCompletionData
protected BashCompletion getCompletionData(OptionMetadata option)
Gets the completion info for an option- Parameters:
option
- Option- Returns:
- Completion data,
null
if none specified
-
getCompletionData
protected BashCompletion getCompletionData(ArgumentsMetadata arguments)
Gets the completion info for arguments- Parameters:
arguments
- Arguments- Returns:
- Completion data,
null
if none specified
-
getCompletionData
protected BashCompletion getCompletionData(java.util.Collection<Accessor> accessors)
-
-