Skip to content

Commit

Permalink
added --verify (#87)
Browse files Browse the repository at this point in the history
Checks configuration file if it exists, then loads the data
  • Loading branch information
andremanzo1 authored Jul 19, 2023
1 parent 1f43395 commit 7d26c4d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions server/src/main/java/edu/sjsu/moth/server/MothCommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;

import java.io.FileInputStream;
import java.io.File;
import java.util.HashMap;

import java.util.Properties;
@Command(name = "moth-server", mixinStandardHelpOptions = true)
public class MothCommandLine implements Runnable {
@Parameters(index = "0", description = "Config file")
private File configFile;

@CommandLine.Option(names = {"-v","--verify"} ,description = "verify")
private boolean verification;

public final Properties properties = new Properties();

@Parameters(index = "1..*", description = "extra spring arguments")
private String[] springArgs;

Expand All @@ -30,6 +35,22 @@ public static void main(String[] args) {
public void run() {
final var prefix = "spring.";
try {
if(verification){
File f = new File(configFile.toURI());
if(f.isFile()) {

FileInputStream fileInputStream = new FileInputStream(f);
properties.load(fileInputStream);
System.out.println("VERIFIED");

System.exit(1);
}
else
{
System.out.println("File not found, Please input proper configuration file");
System.exit(1);
}
}
MothConfiguration config;
config = new MothConfiguration(configFile);
HashMap<String, Object> defaults = new HashMap<String, Object>();
Expand Down

0 comments on commit 7d26c4d

Please sign in to comment.