Просмотр исходного кода

CLI 1.0.2 - Fixed and improved database installation

Added option to install custom and mod tables from command line,
suggested by @Yeiij
Zoey76 5 лет назад
Родитель
Сommit
edcd9f1179
3 измененных файлов с 20 добавлено и 41 удалено
  1. 1 0
      .gitignore
  2. 1 1
      pom.xml
  3. 18 40
      src/main/java/com/l2jserver/cli/command/database/DatabaseInstallCommand.java

+ 1 - 0
.gitignore

@@ -2,3 +2,4 @@
 .project
 .settings/
 target/
+dumps/

+ 1 - 1
pom.xml

@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.l2jserver</groupId>
 	<artifactId>l2j-server-cli</artifactId>
-	<version>1.0.1</version>
+	<version>1.0.2</version>
 	<name>L2J Server Command Line</name>
 	<properties>
 		<maven.compiler.source>11</maven.compiler.source>

+ 18 - 40
src/main/java/com/l2jserver/cli/command/database/DatabaseInstallCommand.java

@@ -19,7 +19,6 @@
 package com.l2jserver.cli.command.database;
 
 import java.io.File;
-import java.util.Scanner;
 
 import org.aeonbits.owner.Mutable;
 
@@ -37,53 +36,38 @@ import picocli.CommandLine.Option;
 /**
  * Database install command.
  * @author Zoey76
- * @version 1.0.0
+ * @version 1.0.2
  */
 @Command(name = "install")
 public class DatabaseInstallCommand extends AbstractCommand {
 	
-	@Option(names = {
-		"-l",
-		"--sql-location"
-	}, required = true, description = "Files location")
+	@Option(names = "-sql", required = true, description = "SQL Files location")
 	private String path;
 	
-	@Option(names = {
-		"-url",
-		"--database-url"
-	}, description = "Database URL")
+	@Option(names = "-url", description = "Database URL")
 	private String url;
 	
-	@Option(names = {
-		"-db",
-		"--database-name"
-	}, description = "Database Name")
+	@Option(names = "-db", description = "Database Name")
 	private String name;
 	
-	@Option(names = {
-		"-u",
-		"--database-user"
-	}, description = "Database User")
+	@Option(names = "-u", description = "Database User")
 	private String user;
 	
-	@Option(names = {
-		"-p",
-		"--database-password"
-	}, interactive = true, description = "Database Password")
+	@Option(names = "-p", description = "Database Password")
 	private String password;
 	
-	@Option(names = {
-		"-m",
-		"--mode"
-	}, required = true, description = "Database installation mode")
+	@Option(names = "-m", required = true, description = "Database installation mode")
 	private DatabaseInstallType mode;
 	
-	@Option(names = {
-		"-t",
-		"--type"
-	}, required = true, description = "Server Type")
+	@Option(names = "-t", required = true, description = "Server Type")
 	private ServerType serverType;
 	
+	@Option(names = "-c", description = "Custom Tables")
+	private boolean customs;
+	
+	@Option(names = "-mods", description = "Mods Tables")
+	private boolean mods;
+	
 	@Override
 	public void run() {
 		// Validate files exists
@@ -103,18 +87,12 @@ public class DatabaseInstallCommand extends AbstractCommand {
 		
 		databaseDAO.basic(sqlPath);
 		
-		System.out.print("Install custom tables? (y/N): ");
-		try (var s = new Scanner(FILTER_INPUT_STREAM)) {
-			if (YES.equalsIgnoreCase(s.next())) {
-				databaseDAO.custom(sqlPath);
-			}
+		if (customs) {
+			databaseDAO.custom(sqlPath);
 		}
 		
-		System.out.print("Install mod tables? (y/N): ");
-		try (var s = new Scanner(FILTER_INPUT_STREAM)) {
-			if (YES.equalsIgnoreCase(s.next())) {
-				databaseDAO.mods(sqlPath);
-			}
+		if (mods) {
+			databaseDAO.mods(sqlPath);
 		}
 		
 		System.out.println("Database installation complete.");