Skip to content

Commit 2ee4510

Browse files
author
Vitalii Cherkashyn
committed
command line argument parser
1 parent 94a2cd5 commit 2ee4510

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

arguments-parser/Arguments.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.cherkashyn.vitalii.ldap;
2+
3+
import com.beust.jcommander.DynamicParameter;
4+
import com.beust.jcommander.Parameter;
5+
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
9+
public class Arguments {
10+
11+
@Parameter(names = {"--help"}, description = "list of arguments for ldap authentication", help = true)
12+
boolean isHelp;
13+
14+
@Parameter(names = {"-u", "--url"}, description = "url to ldap", required = true)
15+
String url="ldaps://ubs000001.addp.com:636";
16+
17+
@Parameter(names = {"-p", "--password"}, description = "password of user", required = true)
18+
String password="my_password";
19+
20+
@DynamicParameter(names = {"-d"}, description = "parameters for ldap connection: -dkey=value ", required = true)
21+
Map<String, String> properties=new HashMap<String, String>();
22+
23+
24+
public static void main( String[] args ) {
25+
System.out.println( "--- begin ---" );
26+
27+
Arguments arguments = new Arguments();
28+
JCommander.newBuilder()
29+
.addObject(arguments)
30+
.build()
31+
.parse(args);
32+
if(arguments.isHelp){
33+
new JCommander(arguments, args).usage();
34+
System.exit(0);
35+
}
36+
37+
// contextFactory.createContext(getContextEnvironment(arguments.url, arguments.password, arguments.properties));
38+
// System.out.println(arguments.url);
39+
// System.out.println(arguments.password);
40+
// System.out.println(arguments.properties);
41+
// System.out.println("--- end ---");
42+
// }
43+
//
44+
}
45+

smtp-sender/src/main/java/App.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public static void main(String ... args ) {
6464

6565

6666
/**
67+
* command line parser, read command line arguments
68+
* http://jcommander.org/
6769
* object for reading from DB and sending to SMTP
6870
*/
6971
class SendMessage {

0 commit comments

Comments
 (0)