Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unclebob/javaargs
The Java version of the Args Program.
https://github.com/unclebob/javaargs
Last synced: about 1 month ago
JSON representation
The Java version of the Args Program.
- Host: GitHub
- URL: https://github.com/unclebob/javaargs
- Owner: unclebob
- Created: 2008-12-26T17:29:38.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2020-01-21T17:14:52.000Z (almost 5 years ago)
- Last Synced: 2023-04-12T14:17:33.867Z (over 1 year ago)
- Language: Java
- Homepage: http://butunclebob.com/ArticleS.UncleBob.CleanCodeArgs
- Size: 127 KB
- Stars: 51
- Watchers: 9
- Forks: 52
- Open Issues: 1
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
This is the java version of the Args program described in: http://butunclebob.com/ArticleS.UncleBob.CleanCodeArgs
public class ArgsMain {
public static void main(String[] args) {
try {
Args arg = new Args("l,p#,d*", args);
boolean logging = arg.getBoolean('l');
int port = arg.getInt('p');
String directory = arg.getString('d');
executeApplication(logging, port, directory);
} catch (ArgsException e) {
System.out.printf("Argument error: %s\n", e.errorMessage());
}
}private static void executeApplication(boolean logging, int port, String directory) {
System.out.printf("logging is %s, port:%d, directory:%s\n",logging, port, directory);
}
}Schema:
- char - Boolean arg.
- char* - String arg.
- char# - Integer arg.
- char## - double arg.
- char[*] - one element of a string array.Example schema: (f,s*,n#,a##,p[*])
Coresponding command line: "-f -s Bob -n 1 -a 3.2 -p e1 -p e2 -p e3