Skip to content

Commit 793025a

Browse files
Better help printout
1 parent ff90245 commit 793025a

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

src/main/java/org/radarcns/RestructureAvroRecords.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,14 @@ public class RestructureAvroRecords {
8080

8181
public static void main(String [] args) throws Exception {
8282

83-
parser.setProgramName("hadoop jar restructurehdfs-all-0.3.2.jar");
83+
parser.setProgramName("hadoop jar restructurehdfs-all-0.3.3.jar");
8484
parser.parse(args);
85+
86+
if(commandLineArgs.help) {
87+
parser.usage();
88+
System.exit(0);
89+
}
90+
8591
USE_GZIP = "gzip".equalsIgnoreCase(commandLineArgs.compression);
8692
DO_DEDUPLICATE = commandLineArgs.deduplicate;
8793

src/main/java/org/radarcns/util/commandline/BooleanValidator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ public class BooleanValidator implements IParameterValidator{
77

88
@Override
99
public void validate(String name, String value) throws ParameterException {
10-
if(!value.equalsIgnoreCase("true") && !value.equalsIgnoreCase("false")) {
11-
ParameterException exc = new ParameterException("Parameter " + name + " can only be true or false (found " + value +")");
12-
exc.usage();
13-
throw exc;
10+
if(!value.equalsIgnoreCase("true")
11+
&& !value.equalsIgnoreCase("false")) {
12+
throw new ParameterException("Parameter " + name + " can only be true or "
13+
+ "false (found " + value +"). "
14+
+ "Please run with --help or -h for more information.");
1415
}
1516
}
1617
}

src/main/java/org/radarcns/util/commandline/CommandLineArgs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.beust.jcommander.Parameter;
44

55
public class CommandLineArgs {
6-
@Parameter(names = { "-c", "--compression" }, description = "Compression to use when converting the files. Default is none. Gzip is available.")
6+
@Parameter(names = { "-c", "--compression" }, description = "Compression to use when converting the files. Gzip is available.")
77
public String compression = "none";
88

99
// Default set to false because causes loss of records from Biovotion data. https://github.com/RADAR-base/Restructure-HDFS-topic/issues/16
@@ -19,6 +19,6 @@ public class CommandLineArgs {
1919
@Parameter(names = { "-o", "--output-directory"}, description = "The output folder where the files are to be extracted.", required = true, validateWith = PathValidator.class)
2020
public String outputDirectory;
2121

22-
@Parameter(names = { "-h", "--help"}, help = true)
22+
@Parameter(names = { "-h", "--help"}, help = true, description = "Display the usage of the program with available options.")
2323
public boolean help;
2424
}

src/main/java/org/radarcns/util/commandline/HdfsUriValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public class HdfsUriValidator implements IParameterValidator{
88
@Override
99
public void validate(String name, String value) throws ParameterException {
1010
if (! value.matches("((hdfs)|(webhdfs)):(/?/?)[^\\s]+")) {
11-
ParameterException exc = new ParameterException("Parameter " + name + " should be a valid HDFS or WebHDFS URI. Eg - hdfs://<HOST>:<RPC_PORT>/<PATH>. (found " + value +")");
12-
exc.usage();
13-
throw exc;
11+
throw new ParameterException("Parameter " + name + " should be a valid HDFS or WebHDFS URI. "
12+
+ "Eg - hdfs://<HOST>:<RPC_PORT>/<PATH>. (found " + value
13+
+ "). Please run with --help or -h for more information.");
1414
}
1515
}
1616
}

src/main/java/org/radarcns/util/commandline/PathValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ public class PathValidator implements IParameterValidator{
77
@Override
88
public void validate(String name, String value) throws ParameterException {
99
if (value == null || value.isEmpty()) {
10-
ParameterException exc = new ParameterException("Parameter " + name + " should be supplied. It cannot be empty or null. (found " + value +")");
11-
exc.usage();
12-
throw exc;
10+
throw new ParameterException("Parameter " + name + " should be supplied. "
11+
+ "It cannot be empty or null. (found " + value +")."
12+
+ "Please run with --help or -h for more information.");
1313
}
1414
}
1515
}

0 commit comments

Comments
 (0)