Skip to content

Commit 18aee52

Browse files
authored
Update README
1 parent c526994 commit 18aee52

1 file changed

Lines changed: 36 additions & 14 deletions

File tree

README

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
11
This is the java version of the Args program described in: http://butunclebob.com/ArticleS.UncleBob.CleanCodeArgs
22

3+
4+
---------------------Following parts are updated-----------------------
5+
package com.cleancoder.args;
6+
37
public class ArgsMain {
8+
49
public static void main(String[] args) {
5-
try {
6-
Args arg = new Args("l,p#,d*", args);
7-
boolean logging = arg.getBoolean('l');
8-
int port = arg.getInt('p');
9-
String directory = arg.getString('d');
10-
executeApplication(logging, port, directory);
11-
} catch (ArgsException e) {
12-
System.out.printf("Argument error: %s\n", e.errorMessage());
13-
}
10+
if(args[0].equals("-h")) {
11+
helpFunction();
12+
return;
13+
}
14+
15+
try {
16+
Args arg = new Args("f,p#,s*,n#,a##,d[*]", args);
17+
arg.getAllParameters();
18+
} catch (ArgsException e) {
19+
System.out.printf("Argument error: %s\n", e.errorMessage());
20+
}
1421
}
1522

16-
private static void executeApplication(boolean logging, int port, String directory) {
17-
System.out.printf("logging is %s, port:%d, directory:%s\n",logging, port, directory);
23+
//Function to print the help content
24+
private static void helpFunction() {
25+
System.out.printf("Following are the options : \n");
26+
System.out.printf("Schema: \n - char - Boolean arg.\n - char* - String arg.\n - char# - Integer arg.\n - char## - double arg.\n - char[*] - one element of a string array.\n\n");
27+
System.out.printf("Example schema: (f,p#,s*,n#,a##,d[*])\n\n");
28+
System.out.printf("Corresponding command line: -f -s Bob -n 1 -a 3.2 -p 22 -d /home/users/\n");
1829
}
1930
}
20-
2131
Schema:
2232
- char - Boolean arg.
2333
- char* - String arg.
2434
- char# - Integer arg.
2535
- char## - double arg.
2636
- char[*] - one element of a string array.
2737

28-
Example schema: (f,s*,n#,a##,p[*])
29-
Coresponding command line: "-f -s Bob -n 1 -a 3.2 -p e1 -p e2 -p e3
38+
Example schema: (f,p#,s*,n#,a##,d[*])
39+
Corresponding command line: "-f -s Bob -n 1 -a 3.2 -p 22 -d /home/users/
40+
41+
Code documentation updated
42+
43+
Edited the main to add the schema for what all arguments types.
44+
Added help function and can be used by -h option when running the program.
45+
46+
For Boolean type
47+
-Doesn’t need a value(you just have to specify the argument name)
48+
-Only flag is enough to change to true
49+
50+
Added double and string array code for parsing
3051

52+
String array and map updated to take the value as argument

0 commit comments

Comments
 (0)