Interface Subparsers
-
- All Known Implementing Classes:
SubparsersImpl
public interface SubparsersThis interface defines Subparsers which used to add
Subparser.Subparseris used to add sub-command toArgumentParser.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SubparseraddParser(java.lang.String command)Adds and returnsSubparserobject with given sub-command name.SubparseraddParser(java.lang.String command, boolean addHelp)Adds and returnsSubparserobject with given sub-command name and addHelp.SubparseraddParser(java.lang.String command, boolean addHelp, java.lang.String prefixChars)Adds and returnsSubparserobject with given sub-command name, addHelp and prefixChars.Subparsersdescription(java.lang.String description)Sets the text to display to briefly describe sub-commands in the help message.Subparsersdest(java.lang.String dest)Sets the name of attribute which the selected command name is stored.Subparsershelp(java.lang.String help)Sets the text to display in the help message for sub-commands.Subparsersmetavar(java.lang.String metavar)Sets the text used to represent sub-commands in help messages.Subparserstitle(java.lang.String title)Sets the text to display as a title of sub-commands in the help message.
-
-
-
Method Detail
-
addParser
Subparser addParser(java.lang.String command)
Adds and returns
Subparserobject with given sub-command name. The given command must be unique for each Subparsers instance.The prefixChars is inherited from main ArgumentParser.
- Parameters:
command- Sub-command name- Returns:
Subparserobject.
-
addParser
Subparser addParser(java.lang.String command, boolean addHelp)
Adds and returns
Subparserobject with given sub-command name and addHelp. The given command must be unique for each Subparsers instance.For
addHelp, seeArgumentParsers.newArgumentParser(String, boolean, String). The prefixChars is inherited from main ArgumentParser.- Parameters:
command- Sub-command nameaddHelp- If true,-h/--helpare available. If false, they are not.- Returns:
Subparserobject
-
addParser
Subparser addParser(java.lang.String command, boolean addHelp, java.lang.String prefixChars)
Adds and returns
Subparserobject with given sub-command name, addHelp and prefixChars. The given command must be unique for each Subparsers instance.For
addHelp, seeArgumentParsers.newArgumentParser(String, boolean, String).- Parameters:
command- Sub-command nameaddHelp- If true,-h/--helpare available. If false, they are not.prefixChars- The set of characters that prefix optional arguments.- Returns:
Subparserobject
-
dest
Subparsers dest(java.lang.String dest)
Sets the name of attribute which the selected command name is stored.- Parameters:
dest- The name of attribute the selected command name is stored.- Returns:
- this.
-
help
Subparsers help(java.lang.String help)
Sets the text to display in the help message for sub-commands.- Parameters:
help- The text to display in the help message.- Returns:
- this
-
title
Subparsers title(java.lang.String title)
Sets the text to display as a title of sub-commands in the help message.
If either title or description(
description(String)) is specified, sub-command help will be displayed in its own group.- Parameters:
title- The text to display as a title of sub-commands- Returns:
- this
-
description
Subparsers description(java.lang.String description)
Sets the text to display to briefly describe sub-commands in the help message.
If either description or title(
title(String)) is specified, sub-command help will be displayed in its own group.- Parameters:
description- The text to display to briefly describe sub-commands- Returns:
- this
-
metavar
Subparsers metavar(java.lang.String metavar)
Sets the text used to represent sub-commands in help messages.
By default, text to represent sub-commands are concatenation of all sub-commands. This method can override this default behavior and sets arbitrary string to use. This is useful if there are many sub-commands and you don't want to show them all.
- Parameters:
metavar- The text used to represent sub-commands in help messages- Returns:
- this
-
-