Class CmdLineParser
java.lang.Object
com.github.rjeschke.txtmark.cmd.CmdLineParser
Generic command line parser.
This is a copy from
}.
invalid @link
{@link https://github.com/rjeschke/neetutils-base
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static final classprivate static final classprivate static classprivate static final class(package private) static enum -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final Class<?>[](package private) static final HashMap<Class<?>, CmdLineParser.Type> (package private) static final CmdLineParser.Type[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static StringdefaultToString(Object value, CmdLineParser.Type type, CmdLineParser.Arg arg) static StringgenerateHelp(int columnWidth, boolean sort, Object... objs) Generates a formatted help (Unix-style) for the given argument objects.(package private) static CmdLineParser.TypegetTypeFor(Class<?> clazz) Parses command line arguments.private static voidparseArgs(Object[] objs, List<CmdLineParser.Arg> allArgs, HashMap<String, CmdLineParser.Arg> shortArgs, HashMap<String, CmdLineParser.Arg> longArgs)
-
Field Details
-
TYPE_MAP
-
TYPE_CLASS_LIST
-
TYPE_TYPE_LIST
-
BOOL_TRUE
-
BOOL_FALSE
-
-
Constructor Details
-
CmdLineParser
private CmdLineParser()
-
-
Method Details
-
getTypeFor
-
defaultToString
-
parseArgs
private static void parseArgs(Object[] objs, List<CmdLineParser.Arg> allArgs, HashMap<String, CmdLineParser.Arg> shortArgs, HashMap<String, CmdLineParser.Arg> longArgs) throws IOException - Throws:
IOException
-
generateHelp
Generates a formatted help (Unix-style) for the given argument objects.- Parameters:
columnWidth- Maximum column width. Words get wrapped at spaces.sort- Settrueto sort arguments before printing.objs- One or more objects with annotated public fields.- Returns:
- The formatted argument help text.
- Throws:
IOException- if a parsing error occurred.- See Also:
-
parse
Parses command line arguments.- Parameters:
args- Array of arguments, like the ones provided byvoid main(String[] args)objs- One or more objects with annotated public fields.- Returns:
- A
Listcontaining all unparsed arguments (i.e. arguments that are no switches) - Throws:
IOException- if a parsing error occurred.- See Also:
-