Skip to content

Commit

Permalink
Fix mandatory options bug when -help is used. Fix missing check on -o…
Browse files Browse the repository at this point in the history
…utFile option.
  • Loading branch information
emaiannone committed Jun 20, 2022
1 parent 2d8ef38 commit 39bb882
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/java/org/surface/surface/cli/CLIArgumentsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public static RunningMode<?> parse(String[] args) throws ParseException {
// Interpret Output File to get the Writer
String outFileValue = commandLine.getOptionValue(CLIOptions.OUT_FILE);
FileWriter writer;
if (outFileValue == null) {
throw new IllegalArgumentException("The output file must be indicated.");
}
try {
writer = OutFileInterpreter.interpretOutString(outFileValue);
} catch (IllegalArgumentException e) {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/surface/surface/cli/CLIOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,16 @@ public class CLIOptions extends Options {
private CLIOptions() {
Option target = Option.builder(TARGET)
.hasArg(true)
.required(true)
.desc("Path to either (i) a local non-git directory (LOCAL_DIR), (ii) a local git directory (LOCAL_GIT), (iii) a remote URL to a GitHub repository (REMOTE_GIT), or (iv) a local path to a YAML file (FLEXIBLE). SURFACE behaves differently depending on the type of target: (LOCAL_DIR) it scans the specified directory recursively to search for .java files to analyze; (LOCAL_GIT) it behaves like in LOCAL but allows the selection of specific revisions; (REMOTE_GIT) it clones the GitHub repository inside the directory indicated by the -" + WORK_DIR + " option and runs the analysis on it, also allowing the selection of specific revisions; (FLEXIBLE) parses the YAML that dictates how SURFACE must operate. The specification of the YAML file for FLEXIBLE mode are reported in the README at https://github.com/emaiannone/surface. All the directories cloned during the execution of SURFACE will be deleted at the end (either successful or erroneous).")
.build();

Option workDir = Option.builder(WORK_DIR)
.hasArg(true)
.required(true)
.desc("Path to a local directory where repositories will be copied (LOCAL_GIT or FLEXIBLE) or cloned (REMOTE_GIT or FLEXIBLE). Not evaluated in LOCAL_DIR mode. In FLEXIBLE mode this option represents the default directory where all remote repositories are cloned when not specified differently in the YAML file.")
.build();

Option outFile = Option.builder(OUT_FILE)
.hasArg(true)
.required(true)
.desc("Path to a file where to store the results. If the file already exists, its content will be overwritten. The output format is determined by the extension of the supplied filename. Currently, SURFACE only supports JSON files (with .json extension).")
.build();

Expand Down

0 comments on commit 39bb882

Please sign in to comment.