Boolean, Integer and String fields are supported.
example: to setup --filename as a flag. in class Foo with flag help.
Note: classes with identical flag field names will get overwritten with the last one processed. TODO(rayc) support collision detection and use fully qualified class name for flag option. @author r@kuci.org (Ray Colline)public class FooBean { {@literal @}Flag(help = "config file for foobean") {@literal @}ConfigFile private String configFileName = "/etc/configfile"; {@literal @}Flag(help = "filename to access") private String filename = "/tmp/defaultfile"; public getFilename() { return filename; } public setFilename(String filename) { this.filename = filename; } } public class Foo { public static void main(String[] args) { FooBean fooBean = new FooBean(); BeanCliHelper cliHelper = new BeanCliHelper(); cliHelper.register(fooBean); cliHelper.parse(args); System.stdout.println("Filename is " + fooBean.getFilename()); } }
|
|