类 SimpleCommandLinePropertySource


public class SimpleCommandLinePropertySource extends CommandLinePropertySource<CommandLineArgs>
CommandLinePropertySource implementation backed by a simple String array.

Purpose

This CommandLinePropertySource implementation aims to provide the simplest possible approach to parsing command line arguments. As with all CommandLinePropertySource implementations, command line arguments are broken into two distinct groups: option arguments and non-option arguments, as described below (some sections copied from Javadoc for SimpleCommandLineArgsParser):

Working with option arguments

Option arguments must adhere to the exact syntax:

--optName[=optValue]

That is, options must be prefixed with "--" and may or may not specify a value. If a value is specified, the name and value must be separated without spaces by an equals sign ("="). The value may optionally be an empty string.

Valid examples of option arguments


 --foo
 --foo=
 --foo=""
 --foo=bar
 --foo="bar then baz"
 --foo=bar,baz,biz
 

Invalid examples of option arguments


 -foo
 --foo bar
 --foo = bar
 --foo=bar --foo=baz --foo=biz
 

Working with non-option arguments

Any and all arguments specified at the command line without the "--" option prefix will be considered as "non-option arguments" and made available through the CommandLineArgs.getNonOptionArgs() method.

Typical usage


 public static void main(String[] args) {
     PropertySource<?> ps = new SimpleCommandLinePropertySource(args);
     // ...
 }
 
See CommandLinePropertySource for complete general usage examples.

Beyond the basics

When more fully-featured command line parsing is necessary, consider using the provided JOptCommandLinePropertySource, or implement your own CommandLinePropertySource against the command line parsing library of your choice.

从以下版本开始:
4.0
作者:
Chris Beams, Harry Yang
另请参阅: